diff --git a/calcite-rs-jni/calcite b/calcite-rs-jni/calcite index 046eb9b..d451385 160000 --- a/calcite-rs-jni/calcite +++ b/calcite-rs-jni/calcite @@ -1 +1 @@ -Subproject commit 046eb9ba6d7ecdc30290341330dcaad87b23206c +Subproject commit d4513853cb8352ef2d82fdbece4f3fadbff7434e diff --git a/calcite-rs-jni/jni/src/main/java/com/hasura/CalciteQuery.java b/calcite-rs-jni/jni/src/main/java/com/hasura/CalciteQuery.java index 45f7337..b290c6f 100644 --- a/calcite-rs-jni/jni/src/main/java/com/hasura/CalciteQuery.java +++ b/calcite-rs-jni/jni/src/main/java/com/hasura/CalciteQuery.java @@ -26,6 +26,7 @@ import java.util.List; import java.sql.*; import java.util.*; +import java.util.regex.Pattern; class ExportedKey { String pkTableCatalog; @@ -118,6 +119,7 @@ public static void setClassLoader() { Connection connection; CalciteSchema rootSchema; + boolean sqliteFlag; public static void noOpMethod() { Span span = tracer.spanBuilder("noOpMethod").startSpan(); @@ -268,7 +270,7 @@ private Map getTableColumnInfo(TableMetadata table) { String schemaName = table.schema; CalciteSchema schemaPlus = rootSchema.getSubSchema(schemaName, true); Schema schema = schemaPlus.schema; - boolean sqliteFlag = false; + sqliteFlag = false; if (schema instanceof JdbcSchema) { sqliteFlag = ((JdbcSchema) schema).dialect instanceof SQLiteSqlDialect; } @@ -467,6 +469,7 @@ public String queryModels(String query, String parentTraceId, String parentSpanI try { ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); + Pattern timestampPattern = Pattern.compile("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"); while (resultSet.next()) { Map columns = new LinkedHashMap<>(); @@ -486,6 +489,9 @@ public String queryModels(String query, String parentTraceId, String parentSpanI columns.put(metaData.getColumnLabel(i), rfcDateString); } else if (value instanceof ArrayImpl) { columns.put(metaData.getColumnLabel(i), ((ArrayImpl) value).getArray()); + } else if (sqliteFlag && value instanceof String && metaData.getColumnLabel(i).toLowerCase().contains("date") && timestampPattern.matcher((String) value).matches()) { + String newDate = ((String) value).replace(" ", "T"); + columns.put(metaData.getColumnLabel(i), newDate); } // if it is not date - put the value directly else { diff --git a/calcite-rs-jni/py_graphql_sql/py_graphql_sql/__init__.py b/calcite-rs-jni/py_graphql_sql/py_graphql_sql/__init__.py index 02a8e84..881cce5 100644 --- a/calcite-rs-jni/py_graphql_sql/py_graphql_sql/__init__.py +++ b/calcite-rs-jni/py_graphql_sql/py_graphql_sql/__init__.py @@ -23,7 +23,7 @@ try: logger.debug("Attempting to register the 'hasura.py_graphql_sql' dialect.") registry.register('hasura.py_graphql_sql', 'py_graphql_sql.sqlalchemy.hasura.ddnbase', 'HasuraDDNDialect') - registry.register('hasura', 'py_graphql_sql.sqlalchemy.hasura.ddnbase', 'HasuraDDNDialect') + # registry.register('hasura', 'py_graphql_sql.sqlalchemy.hasura.ddnbase', 'HasuraDDNDialect') logger.debug(registry.load('hasura.py_graphql_sql')) logger.debug("Successfully registered the 'hasura.py_graphql_sql' dialect.") except Exception as e: diff --git a/calcite-rs-jni/py_graphql_sql/pyproject.toml b/calcite-rs-jni/py_graphql_sql/pyproject.toml index 6fddf2c..5820c91 100644 --- a/calcite-rs-jni/py_graphql_sql/pyproject.toml +++ b/calcite-rs-jni/py_graphql_sql/pyproject.toml @@ -35,7 +35,6 @@ homepage = "https://github.com/hasura/ndc-calcite" [project.entry-points."sqlalchemy.dialects"] "hasura.py_graphql_sql" = "py_graphql_sql.sqlalchemy.hasura.ddnbase:HasuraDDNDialect" -"hasura" = "py_graphql_sql.sqlalchemy.hasura.ddnbase:HasuraDDNDialect" [tool.setuptools] packages = { find = {} } diff --git a/calcite-rs-jni/py_graphql_sql/test.py b/calcite-rs-jni/py_graphql_sql/test.py index 9241af2..c95a0b9 100644 --- a/calcite-rs-jni/py_graphql_sql/test.py +++ b/calcite-rs-jni/py_graphql_sql/test.py @@ -17,7 +17,7 @@ try: # registered_dialects = list(registry._entry_points.keys()) - dialect_names = list(sqlalchemy.dialects.registry.impls) + dialect_names = list(sqlalchemy.dialects.registry.impls) + list(sqlalchemy.dialects.__all__) print(dialect_names) print(f"\nCreating engine with URL: {url}") engine = create_engine(url, echo=True)