Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Calcite return type override for FROM_DATE_TIME scalar function in PinotOperatorTable #14075

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public void testSelectWithCastAndFilterQueries(boolean useMultiStageQueryEngine)
+ "FROM %s\n"
+ "WHERE CAST(DATETRUNC('DAY', CAST(FROMDATETIME(TODATETIME(FROMDATETIME(CAST(CAST(tsBase AS TIMESTAMP) AS "
+ "VARCHAR), 'yyyy-MM-dd HH:mm:ss.S'), 'yyyy-MM-dd'), 'yyyy-MM-dd') AS TIMESTAMP), 'MILLISECONDS') AS "
+ "TIMESTAMP) = FROMDATETIME( '2019-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')\n", getTableName());
+ "TIMESTAMP) = CAST(FROMDATETIME( '2019-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss') AS TIMESTAMP)\n",
getTableName());
JsonNode jsonNode = postQuery(query);
assertEquals(jsonNode.get("resultTable").get("rows").size(), 1);
assertEquals(jsonNode.get("resultTable").get("rows").get(0).get(0).asText(), "2019-01-01 00:00:00.0");
Expand All @@ -162,19 +163,11 @@ public void testSelectWithStringCastAndFilterQueries(boolean useMultiStageQueryE
+ "LIMIT 5", getTableName());
JsonNode jsonNode = postQuery(query);
assertEquals(jsonNode.get("resultTable").get("rows").size(), 5);
if (useMultiStageQueryEngine) {
assertEquals(jsonNode.get("resultTable").get("rows").get(0).get(0).asText(), "2018-12-31 23:00:00.0");
assertEquals(jsonNode.get("resultTable").get("rows").get(1).get(0).asText(), "2019-01-01 23:00:00.0");
assertEquals(jsonNode.get("resultTable").get("rows").get(2).get(0).asText(), "2019-01-02 23:00:00.0");
assertEquals(jsonNode.get("resultTable").get("rows").get(3).get(0).asText(), "2019-01-03 23:00:00.0");
assertEquals(jsonNode.get("resultTable").get("rows").get(4).get(0).asText(), "2019-01-04 23:00:00.0");
} else {
assertEquals(jsonNode.get("resultTable").get("rows").get(0).get(0).asText(), "1546297200000");
assertEquals(jsonNode.get("resultTable").get("rows").get(1).get(0).asText(), "1546383600000");
assertEquals(jsonNode.get("resultTable").get("rows").get(2).get(0).asText(), "1546470000000");
assertEquals(jsonNode.get("resultTable").get("rows").get(3).get(0).asText(), "1546556400000");
assertEquals(jsonNode.get("resultTable").get("rows").get(4).get(0).asText(), "1546642800000");
}
assertEquals(jsonNode.get("resultTable").get("rows").get(0).get(0).asText(), "1546297200000");
assertEquals(jsonNode.get("resultTable").get("rows").get(1).get(0).asText(), "1546383600000");
assertEquals(jsonNode.get("resultTable").get("rows").get(2).get(0).asText(), "1546470000000");
assertEquals(jsonNode.get("resultTable").get("rows").get(3).get(0).asText(), "1546556400000");
assertEquals(jsonNode.get("resultTable").get("rows").get(4).get(0).asText(), "1546642800000");
}

@Test(dataProvider = "useBothQueryEngines")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,7 @@ public static PinotOperatorTable instance() {
// SqlStdOperatorTable.COALESCE without rewrite
new SqlFunction("COALESCE", SqlKind.COALESCE,
ReturnTypes.LEAST_RESTRICTIVE.andThen(SqlTypeTransforms.LEAST_NULLABLE), null, OperandTypes.SAME_VARIADIC,
SqlFunctionCategory.SYSTEM),

// The scalar function version returns long instead of Timestamp
// TODO: Consider unifying the return type to Timestamp
new PinotSqlFunction("FROM_DATE_TIME", ReturnTypes.TIMESTAMP_NULLABLE, OperandTypes.family(
List.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.ANY),
i -> i > 1))
SqlFunctionCategory.SYSTEM)
);

private static final List<Pair<SqlOperator, List<String>>> PINOT_OPERATORS_WITH_ALIASES = List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"sql": "EXPLAIN PLAN FOR SELECT FROMDATETIME( '1997-02-01 00:00:00', 'yyyy-MM-dd HH:mm:ss') FROM d",
"output": [
"Execution Plan",
"\nLogicalProject(EXPR$0=[1997-02-01 00:00:00])",
"\nLogicalProject(EXPR$0=[854755200000:BIGINT])",
"\n LogicalTableScan(table=[[default, d]])",
"\n"
]
Expand All @@ -52,10 +52,10 @@
},
{
"description": "Select fromdatetime function in where clause",
"sql": "EXPLAIN PLAN FOR SELECT * FROM d WHERE CAST(ts AS TIMESTAMP) = FROMDATETIME('2019-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')",
"sql": "EXPLAIN PLAN FOR SELECT * FROM d WHERE ts = FROMDATETIME('2019-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')",
"output": [
"Execution Plan",
"\nLogicalFilter(condition=[=(CAST($6):TIMESTAMP(0) NOT NULL, 2019-01-01 00:00:00)])",
"\nLogicalFilter(condition=[=($6, 1546300800000)])",
"\n LogicalTableScan(table=[[default, d]])",
"\n"
]
Expand Down
Loading