zhztheplayer commented on a change in pull request #1262: [CALCITE-2804] fix
broken unit test
URL: https://github.com/apache/calcite/pull/1262#discussion_r292263637
##########
File path: druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
##########
@@ -577,23 +577,22 @@ protected boolean enabled() {
*/
@Test public void testCastToTimestamp() {
final String sql = "select cast(\"timestamp\" as timestamp) from
\"foodmart\"";
- final String druidQuery = "{'queryType':'scan','dataSource':'foodmart',"
- + "'intervals':['1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z']',"
- + "'virtualColumns:[{'type':'expression','name':'vc',"
- + "'expression':'timestamp_parse("
- +
"timestamp_format(\"__time\",'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027',"
- +
"'America/New_York'),'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','UTC')',"
- + "'outputType':'LONG'}],"
- + "'columns':['vc'],"
- + "'resultFormat':'compactedList'}";
+ final String druidQuery = "timestamp_format(\\\"__time\\\","
+ + "'yyyy-MM-dd\\\\u0027T\\\\u0027HH:mm:ss.SSS\\\\u0027Z\\\\u0027',"
+ +
"'America/New_York'),'yyyy-MM-dd\\\\u0027T\\\\u0027HH:mm:ss.SSS\\\\u0027Z\\\\u0027','UTC')\"";
CalciteAssert.that()
.enable(enabled())
.withModel(FOODMART)
.with(CalciteConnectionProperty.TIME_ZONE.camelName(),
"America/New_York")
.query(sql)
.runs()
- .queryContains(druidChecker(druidQuery));
Review comment:
Queries are JSONs. The purpose of calling "druidChecker" is to convert
strings' single quotes in JSON to double quotes. With our druidChecker
implementation, single quotes that don't indicate strings (they might inside a
string) are incorrectly converted to double also, so we need an individual
implementation. My non-blocking suggestion is to check the expression in JSON
only:
```
timestamp_parse(timestamp_format("__time",'yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027','America/New_York'),'yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027','UTC')
```
, to prevent double-quote JSON from appearing in "expected".
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services