Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.35.0, 1.36.0
-
None
-
None
Description
TO_TIMESTAMP doesn't work... it leads to java.lang.RuntimeException: cannot translate call TO_TIMESTAMP($t1, $t2)
PARSE_TIMESTAMP works good
import org.apache.calcite.adapter.jdbc.JdbcSchema; import org.apache.calcite.avatica.util.Casing; import org.apache.calcite.config.CalciteConnectionProperty; import org.apache.calcite.jdbc.CalciteConnection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties; import org.apache.calcite.jdbc.Driver; import org.apache.calcite.schema.SchemaPlus; import javax.sql.DataSource; public class Test { public static void main(String[] args) throws SQLException { CalciteConnection connection = initCalciteConnection(); DataSource oracleDataSource1 = JdbcSchema.dataSource( "jdbc:oracle:thin:@//<ip>:<port>/<service>", "oracle.jdbc.OracleDriver", "<user>", "<password>" ); String schemaName = "oracle_1"; SchemaPlus rootSchema = connection.getRootSchema(); JdbcSchema jdbcSchema = JdbcSchema.create(rootSchema, schemaName, oracleDataSource1, null, "<schema>"); rootSchema.add(schemaName, jdbcSchema); // String sql = """ // SELECT PARSE_TIMESTAMP('%d.%m.%Y %H:%M:%S', '01.01.2024 00:00:00') // """; String sql = """ SELECT TO_TIMESTAMP('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') """; ResultSet resultSet = connection.createStatement().executeQuery(sql); while (resultSet.next()) { for (int i=1; i <= resultSet.getMetaData().getColumnCount(); i++) { System.out.println(resultSet.getString(i)); System.out.println(" "); } System.out.println(" "); } } private static CalciteConnection initCalciteConnection() throws SQLException { DriverManager.registerDriver(new Driver()); Properties properties = new Properties(); // properties.putIfAbsent(CalciteConnectionProperty.FUN.camelName(), "oracle,postgresql,bigquery"); properties.putIfAbsent(CalciteConnectionProperty.FUN.camelName(), "all"); properties.putIfAbsent(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), "false"); properties.putIfAbsent(CalciteConnectionProperty.QUOTED_CASING.camelName(), Casing.UNCHANGED.name()); properties.putIfAbsent(CalciteConnectionProperty.UNQUOTED_CASING.camelName(), Casing.UNCHANGED.name()); return DriverManager.getConnection("jdbc:calcite:", properties).unwrap(CalciteConnection.class); } }
Attachments
Issue Links
- relates to
-
CALCITE-6315 Support PostgreSQL TO_DATE, TO_TIMESTAMP
- Closed