bziobrowski commented on code in PR #14388:
URL: https://github.com/apache/pinot/pull/14388#discussion_r1828975156
##########
pinot-core/src/test/java/org/apache/pinot/core/query/QueryParseErrorReportingTest.java:
##########
@@ -0,0 +1,228 @@
+package org.apache.pinot.core.query;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.FunctionContext;
+import org.apache.pinot.core.common.PinotRuntimeException;
+import
org.apache.pinot.core.query.aggregation.function.AbstractAggregationFunctionTest;
+import
org.apache.pinot.core.query.aggregation.function.AggregationFunctionFactory;
+import
org.apache.pinot.core.query.aggregation.function.TestAggregationFunction;
+import org.apache.pinot.queries.FluentQueryTest;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.mockito.ArgumentMatcher;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+public class QueryParseErrorReportingTest extends
AbstractAggregationFunctionTest {
+
+ private static final String RAW_TABLE_NAME = "parkingData";
+
+ private static final String IS_OCCUPIED_COLUMN = "isOccupied";
+ private static final String LEVEL_ID_COLUMN = "levelId";
+ private static final String LOT_ID_COLUMN = "lotId";
+ private static final String EVENT_TIME_COLUMN = "eventTime";
+
+ private static final DateTimeFormatSpec FORMATTER =
+ new DateTimeFormatSpec("1:MILLISECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd
HH:mm:ss.SSS");
+
+ @Test
+ public void testNoKeyAggregateConversionError() {
+ FluentQueryTest.withBaseDir(_baseDir)
+ .withNullHandling(false)
+
.givenTable(SINGLE_FIELD_NULLABLE_DIMENSION_SCHEMAS.get(FieldSpec.DataType.STRING),
+ SINGLE_FIELD_TABLE_CONFIG)
+ .onFirstInstance(
+ new Object[]{"A"}
+ )
+ .andOnSecondInstance(
+ new Object[]{"1A"}
+ )
+ .whenQuery("select max(myField) from testTable")
+ .thenResultIsException(
+ "Error when processing
testTable.myField.*NumberFormatException: For input string:", 2);
+ }
+
+ @Test
+ public void testKeyedAggregateConversionError() {
+ FluentQueryTest.withBaseDir(_baseDir)
+ .withNullHandling(false)
+ .givenTable(
+ new Schema.SchemaBuilder()
+ .setSchemaName("testTable")
+ .setEnableColumnBasedNullHandling(true)
+ .addDimensionField("key", FieldSpec.DataType.STRING)
+ .addDimensionField("value",
FieldSpec.DataType.STRING)
+ .build(), SINGLE_FIELD_TABLE_CONFIG)
+ .onFirstInstance(
+ new Object[]{"k1", "v10"}
+ )
+ .andOnSecondInstance(
+ new Object[]{"k2", "20v"}
+ )
+ .whenQuery("select key, max(value) from testTable group by
key")
+ .thenResultIsException(
+ "Error when processing
testTable.value.*NumberFormatException: For input string:", 2);
+ }
+
+ @Test(dataProvider = "dataTypes")
+ public void testGapFillConversionError(FieldSpec.DataType functionType,
boolean nullHandlingEnabled) {
+ String query = "SELECT "
+ + " time_col, TEST_AGG( occupied, '" + functionType + "' ) as
occupied_slots_count "
+ + "FROM ( "
+ + " SELECT GapFill(time_col, '1:MILLISECONDS:EPOCH', '1636257600000',
'1636286400000', '1:HOURS',"
+ + " FILL( occupied, 'FILL_PREVIOUS_VALUE'), "
+ + " TIMESERIESON(levelId, lotId) ) AS time_col,"
+ + " occupied , lotId, levelId"
+ + " FROM ("
+ + " SELECT DATETRUNC('hour', eventTime, 'milliseconds') AS
time_col, "
+ + " lastWithTime(isOccupied, eventTime, 'STRING') as
occupied, "
+ + " lotId, levelId "
+ + " FROM parkingData "
+ + " GROUP BY time_col, levelId, lotId"
+ + " LIMIT 200 "
+ + " ) "
+ + " LIMIT 200 "
+ + ") "
+ + " GROUP BY time_col ";
+
Review Comment:
I think it might be better to add test function to registry but make it work
only if a system flag is set, e.g. enableTestFunctions, than to rely on fragile
mocks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]