[ https://issues.apache.org/jira/browse/CALCITE-6405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Alekseev closed CALCITE-6405. ---------------------------------- Fix Version/s: 1.37.0 Resolution: Won't Fix Fixed in 1.37 > TO_TIMESTAMP doesn't work > ------------------------- > > Key: CALCITE-6405 > URL: https://issues.apache.org/jira/browse/CALCITE-6405 > Project: Calcite > Issue Type: Bug > Affects Versions: 1.35.0, 1.36.0 > Reporter: Oleg Alekseev > Priority: Major > Fix For: 1.37.0 > > > TO_TIMESTAMP doesn't work... it leads to java.lang.RuntimeException: cannot > translate call TO_TIMESTAMP($t1, $t2) > PARSE_TIMESTAMP works good > {code:java} > 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); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)