flo076 commented on PR #35472:
URL: https://github.com/apache/beam/pull/35472#issuecomment-3018636877

   Hello @liferoad ,
   thanks for this pull request but i think is not enough 
   I try your modification on my side and i have an error when i try to execute 
a new test in JdbcDriverTest.java.
   According to the calcite documentation "BIT_COUNT" function is available 
only with bigquery dialect.
   
   I continue to investigate on my side. 
   
   NOTE : this test is for debugging purpose.
   
   ```java
   @Test
     public void testInternalConnect_unbounded_limit_bq() throws Exception {
       ReadOnlyTableProvider tableProvider =
           new ReadOnlyTableProvider(
               "test",
               ImmutableMap.of(
                   "test",
                   TestUnboundedTable.of(
                           Schema.FieldType.INT32, "order_id",
                           Schema.FieldType.INT32, "site_id",
                           Schema.FieldType.INT32, "price",
                           Schema.FieldType.STRING, "label",
                           Schema.FieldType.STRING, "date",
                           Schema.FieldType.DATETIME, "order_time")
                       .timestampColumnIndex(5)
                       .addRows(
                           Duration.ZERO,
                           1,
                           1,
                           1,
                           "test-1",
                           "2025-06-30",
                           FIRST_DATE,
                           1,
                           2,
                           6,
                           "test-2",
                           "2025-06-30",
                           FIRST_DATE)));
       BeamSqlPipelineOptions options =
           PipelineOptionsFactory.create().as(BeamSqlPipelineOptions.class);
       options.setCalciteConnectionDialect("BIGQUERY");
   
       CalciteConnection connection = JdbcDriver.connect(tableProvider, 
options);
       assertEquals(
           "BIGQUERY", connection.getProperties().getProperty("fun", 
"CALCITE").toUpperCase());
       Statement statement = connection.createStatement();
   
       ResultSet resultSet1 =
           statement.executeQuery("SELECT SUBSTRING(`label`,2), 
BIT_COUNT(`price`) FROM test LIMIT 1");
       assertTrue(resultSet1.next());
       System.out.println("DEBUG " + resultSet1.getString(1));
       System.out.println("DEBUG " + resultSet1.getInt(2));
       //    System.out.println(resultSet1.getInt(2));
       assertFalse(resultSet1.next());
   
       ResultSet resultSet2 = statement.executeQuery("SELECT * FROM test LIMIT 
2");
       assertTrue(resultSet2.next());
       assertTrue(resultSet2.next());
       assertFalse(resultSet2.next());
     }
   ```
   
   I already tried with calcite native functions and everything is alright
   ```java
   @Test
     public void testInternalConnect_unbounded_limit_bq_native() throws 
Exception {
       ReadOnlyTableProvider tableProvider =
           new ReadOnlyTableProvider(
               "test",
               ImmutableMap.of(
                   "test",
                   TestUnboundedTable.of(
                           Schema.FieldType.INT32, "order_id",
                           Schema.FieldType.INT32, "site_id",
                           Schema.FieldType.INT32, "price",
                           Schema.FieldType.STRING, "label",
                           Schema.FieldType.STRING, "date",
                           Schema.FieldType.DATETIME, "order_time")
                       .timestampColumnIndex(5)
                       .addRows(
                           Duration.ZERO,
                           1,
                           1,
                           1,
                           "test-1",
                           "2025-06-30",
                           FIRST_DATE,
                           1,
                           2,
                           6,
                           "test-2",
                           "2025-06-30",
                           FIRST_DATE)));
       BeamSqlPipelineOptions options =
           PipelineOptionsFactory.create().as(BeamSqlPipelineOptions.class);
       options.setCalciteConnectionDialect("BIGQUERY");
   
       CalciteConnection connection = JdbcDriver.connect(tableProvider, 
options);
       assertEquals(
           "BIGQUERY", connection.getProperties().getProperty("fun", 
"CALCITE").toUpperCase());
       Statement statement = connection.createStatement();
   
       ResultSet resultSet1 =
           statement.executeQuery(
               "SELECT SUBSTRING(`label`,2), CAST(`date` AS DATE) FROM test 
LIMIT 1");
       assertTrue(resultSet1.next());
       System.out.println("DEBUG " + resultSet1.getString(1));
       System.out.println("DEBUG " + resultSet1.getDate(2));
       //    System.out.println(resultSet1.getInt(2));
       assertFalse(resultSet1.next());
   
       ResultSet resultSet2 = statement.executeQuery("SELECT * FROM test LIMIT 
2");
       assertTrue(resultSet2.next());
       assertTrue(resultSet2.next());
       assertFalse(resultSet2.next());
     }
   ```
   


-- 
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]

Reply via email to