From c87ba9a646c7627564f5ad992562b97c6e64a11d Mon Sep 17 00:00:00 2001 From: Nathaniel Bauernfeind Date: Mon, 24 Jun 2024 14:58:10 -0600 Subject: [PATCH] Force column names to take precedence --- .../engine/table/impl/select/MatchFilter.java | 17 ++++++++++++++--- .../engine/table/impl/select/RangeFilter.java | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java index 3114cdcf664..2568b9d7d10 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/MatchFilter.java @@ -224,7 +224,7 @@ public synchronized void init( final Map queryScopeVariables = compilationProcessor.getQueryScopeVariables(); final ColumnTypeConvertor convertor = ColumnTypeConvertorFactory.getConvertor(column.getDataType()); for (String strValue : strValues) { - convertor.convertValue(column, strValue, queryScopeVariables, valueList::add); + convertor.convertValue(column, tableDefinition, strValue, queryScopeVariables, valueList::add); } values = valueList.toArray(); } catch (final RuntimeException err) { @@ -337,9 +337,17 @@ Object convertParamValue(Object paramValue) { */ final boolean convertValue( @NotNull final ColumnDefinition column, + @NotNull final TableDefinition tableDefinition, @NotNull final String strValue, @NotNull final Map queryScopeVariables, @NotNull final Consumer valueConsumer) { + if (tableDefinition.getColumn(strValue) != null) { + // this is also a column name which needs to take precedence, and we can't convert it + throw new IllegalArgumentException(String.format( + "Failed to convert literal value <%s> for column \"%s\" of type %s; it is a column name", + strValue, column.getName(), column.getDataType().getName())); + } + if (queryScopeVariables.containsKey(strValue)) { Object paramValue = queryScopeVariables.get(strValue); if (paramValue != null && paramValue.getClass().isArray()) { @@ -358,12 +366,15 @@ final boolean convertValue( valueConsumer.accept(convertParamValue(paramValue)); return false; } + try { valueConsumer.accept(convertStringLiteral(strValue)); } catch (Throwable t) { - throw new IllegalArgumentException("Failed to convert literal value <" + strValue + - "> for column \"" + column.getName() + "\" of type " + column.getDataType().getName(), t); + throw new IllegalArgumentException(String.format( + "Failed to convert literal value <%s> for column \"%s\" of type %s", + strValue, column.getName(), column.getDataType().getName()), t); } + return false; } } diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeFilter.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeFilter.java index 1b20fef7222..65d65b75e03 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeFilter.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/select/RangeFilter.java @@ -183,7 +183,8 @@ public void init( try { boolean wasAnArrayType = convertor.convertValue( - def, value, compilationProcessor.getQueryScopeVariables(), realValue::setValue); + def, tableDefinition, value, compilationProcessor.getQueryScopeVariables(), + realValue::setValue); if (wasAnArrayType) { conversionError = new IllegalArgumentException("RangeFilter does not support array types for column "