Skip to content

Commit 1d33006

Browse files
committed
Case-insensitive column names
With case-sensitive names, client would add the same column twice if the user used the same name in different case.
1 parent 5d041c5 commit 1d33006

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

core/src/main/java/io/questdb/client/cutlass/qwp/protocol/QwpTableBuffer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.questdb.client.cutlass.qwp.client.QwpWebSocketSender;
3333
import io.questdb.client.std.CharSequenceIntHashMap;
3434
import io.questdb.client.std.Chars;
35+
import io.questdb.client.std.LowerCaseAsciiCharSequenceIntHashMap;
3536
import io.questdb.client.std.Decimal128;
3637
import io.questdb.client.std.Decimal256;
3738
import io.questdb.client.std.Decimal64;
@@ -58,7 +59,7 @@
5859
*/
5960
public class QwpTableBuffer implements QuietCloseable {
6061

61-
private final CharSequenceIntHashMap columnNameToIndex;
62+
private final LowerCaseAsciiCharSequenceIntHashMap columnNameToIndex;
6263
private final ObjList<ColumnBuffer> columns;
6364
private final QwpWebSocketSender sender;
6465
private final String tableName;
@@ -85,7 +86,7 @@ public QwpTableBuffer(String tableName, QwpWebSocketSender sender) {
8586
this.tableName = tableName;
8687
this.sender = sender;
8788
this.columns = new ObjList<>();
88-
this.columnNameToIndex = new CharSequenceIntHashMap();
89+
this.columnNameToIndex = new LowerCaseAsciiCharSequenceIntHashMap();
8990
this.rowCount = 0;
9091
this.schemaHash = 0;
9192
this.schemaHashComputed = false;
@@ -360,7 +361,7 @@ private ColumnBuffer lookupColumn(CharSequence name, byte type) {
360361
int n = columns.size();
361362
if (columnAccessCursor < n) {
362363
ColumnBuffer candidate = fastColumns[columnAccessCursor];
363-
if (Chars.equals(candidate.name, name)) {
364+
if (Chars.equalsIgnoreCase(candidate.name, name)) {
364365
columnAccessCursor++;
365366
assertColumnType(name, type, candidate);
366367
return candidate;
@@ -369,7 +370,7 @@ private ColumnBuffer lookupColumn(CharSequence name, byte type) {
369370

370371
// Slow path: hash map lookup
371372
int idx = columnNameToIndex.get(name);
372-
if (idx != CharSequenceIntHashMap.NO_ENTRY_VALUE) {
373+
if (idx >= 0) {
373374
ColumnBuffer existing = columns.get(idx);
374375
assertColumnType(name, type, existing);
375376
return existing;

0 commit comments

Comments
 (0)