amaliujia commented on a change in pull request #11948:
URL: https://github.com/apache/beam/pull/11948#discussion_r436967724



##########
File path: 
sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLDialectSpecTest.java
##########
@@ -3565,19 +3566,16 @@ public void testCaseWithValueNoElseNoMatch() {
   }
 
   @Test
-  @Ignore(
-      "Codegen generates code that Janino cannot compile, need further 
investigation on root"
-          + " cause.")
   public void testCastToDateWithCase() {
     String sql =
         "SELECT f_int, \n"
             + "CASE WHEN CHAR_LENGTH(TRIM(f_string)) = 8 \n"
             + "    THEN CAST (CONCAT(\n"
-            + "       SUBSTR(TRIM(f_string), 0, 4) \n"
+            + "       SUBSTR(TRIM(f_string), 1, 4) \n"

Review comment:
       SUBSTR count the first char from position 1.

##########
File path: 
sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLDialectSpecTest.java
##########
@@ -3565,19 +3566,16 @@ public void testCaseWithValueNoElseNoMatch() {
   }
 
   @Test
-  @Ignore(
-      "Codegen generates code that Janino cannot compile, need further 
investigation on root"
-          + " cause.")
   public void testCastToDateWithCase() {
     String sql =
         "SELECT f_int, \n"
             + "CASE WHEN CHAR_LENGTH(TRIM(f_string)) = 8 \n"
             + "    THEN CAST (CONCAT(\n"
-            + "       SUBSTR(TRIM(f_string), 0, 4) \n"
+            + "       SUBSTR(TRIM(f_string), 1, 4) \n"

Review comment:
       SUBSTR counts the first char from position 1.

##########
File path: 
sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLDialectSpecTest.java
##########
@@ -3587,11 +3585,14 @@ public void testCastToDateWithCase() {
     PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, 
beamRelNode);
 
     Schema resultType =
-        Schema.builder().addInt32Field("f_int").addNullableField("f_date", 
DATETIME).build();
+        Schema.builder()
+            .addInt64Field("f_long")
+            .addNullableField("f_date", FieldType.logicalType(SqlTypes.DATE))
+            .build();
 
     PAssert.that(stream)
         .containsInAnyOrder(
-            Row.withSchema(resultType).addValues(1, 
parseDate("2018-10-18")).build());
+            Row.withSchema(resultType).addValues(1L, 
parseDateToLocalDate("2018-10-18")).build());

Review comment:
       Thanks!




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to