Skip to content

Add PostgreSQL integration test for SQL enhancer with schema loading and optimization fixes#245

Draft
Copilot wants to merge 58 commits intomainfrom
copilot/add-integration-test-postgres
Draft

Add PostgreSQL integration test for SQL enhancer with schema loading and optimization fixes#245
Copilot wants to merge 58 commits intomainfrom
copilot/add-integration-test-postgres

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

PostgreSQL SQL Enhancer Integration Test - Complete ✅

Current Status

  • All implementation complete
  • Schema loading fully functional
  • Query simplified to use Calcite-compatible SQL
  • Schema name qualification fixed
  • SQL modification detection improved
  • RESOLVED: Test properly skips all setup when disabled via enablePostgresTests property

Implementation Summary

The integration test demonstrates SQL query optimization using Apache Calcite with full schema awareness for PostgreSQL.

Key Fixes Applied:

  1. SQL Enhancer Mode: Configured with -Dojp.sql.enhancer.mode=OPTIMIZE to enable conversion and optimization with schema loading

  2. PostgreSQL Schema Loading: Added automatic detection and default to "public" schema when connection.getSchema() returns null

  3. Query Simplification: Replaced PostgreSQL-specific date_trunc() and now() with standard SQL CURRENT_TIMESTAMP - INTERVAL '30' DAY

  4. Schema Name Qualification: Fixed Calcite's schema registration to use the actual database schema name ("public" for PostgreSQL) instead of hardcoded "default"

  5. SQL Modification Detection: Changed comparison from case-insensitive to case-sensitive to properly detect when Calcite produces optimized SQL with structural improvements

  6. Test Control: Uses standard enablePostgresTests system property to control test execution. Added early return in @BeforeAll setup method when test is disabled to prevent any database connection attempts, ensuring complete skip of all setup code when disabled.

Files Modified:

  1. ojp-jdbc-driver/src/test/resources/sql_enhancer_postgres_test_data.sql - Test data schema
  2. ojp-jdbc-driver/src/test/java/openjproxy/jdbc/PostgresSqlEnhancerIntegrationTest.java - Integration test with proper skip logic in setup
  3. .github/workflows/main.yml - CI workflow with OPTIMIZE mode
  4. ojp-server/src/main/java/org/openjproxy/grpc/server/StatementServiceImpl.java - PostgreSQL schema default handling
  5. ojp-server/src/main/java/org/openjproxy/grpc/server/sql/SqlEnhancerEngine.java - Schema loading infrastructure and modification detection
  6. ojp-server/src/main/java/org/openjproxy/grpc/server/sql/SchemaLoader.java - Enhanced logging
  7. ojp-server/src/main/java/org/openjproxy/grpc/server/sql/RelationalAlgebraConverter.java - Fixed schema name qualification

Test Architecture:

  • Uses two OJP servers from CI postgres-test job (ports 1059 and 10593)
  • Controlled by enablePostgresTests property - disabled by default
  • Early return in setup() when disabled prevents all database operations
  • Skips gracefully without attempting PostgreSQL connections when disabled
  • Test data: 100 regions, 5000 customers, 10000 orders
  • Standard SQL query with joins, filters, and aggregations
  • Performance comparison between baseline and optimized execution

Schema Loading and Enhancement Flow:

  1. Test checks enablePostgresTests property in setup() - returns early if disabled
  2. Server starts with OPTIMIZE mode → SchemaCache and SchemaLoader created
  3. Query arrives → ensureSchemaLoaded() loads metadata from PostgreSQL
  4. SchemaCache stores metadata with schema name="public"
  5. Calcite registers schema using actual name from metadata
  6. Query converted to relational algebra and optimized
  7. Optimized SQL generated with correct schema qualifiers
  8. Case-sensitive comparison detects structural changes
  9. Enhanced SQL properly identified and used for execution

Test Goal

Compares execution time of the same inefficient SQL query with and without SQL enhancement, demonstrating Apache Calcite's query optimization capabilities while maintaining result correctness. The test properly skips all setup and execution when disabled, making it safe to run in any environment.

Original prompt

Do an analysis on what would be required to implement an integration test against postgres database (check how other tests do it and follow), the goal of the test is to test the new sql enhancing functionality, to be able to do that you will have to start two OJP servers, one with SQL enhancing enabled and one without, both in random ports. You might alter the Main CI workflow for this test and add steps there along with when other postgres tests run. The two instances of OJP server should start in random ports. The port should be passed to the test as an argument and the test will consist of this.

I am thinking of a database with preloaded data for tables Regions, Customers and Orders where Regions should have 100 rows, Customers 5000 rows and Orders 10000k rows

An example of an inneficient query might be
SELECT
r.region_name,
count(*) AS order_cnt,
sum(o.amount) AS total_amount
FROM orders o
JOIN customers c
ON c.customer_id = o.customer_id
JOIN regions r
ON r.region_id = c.region_id
WHERE
date_trunc('day', o.order_ts) >= date_trunc('day', now() - interval '30 days')
AND c.status = 'ACTIVE'
GROUP BY r.region_name
ORDER BY total_amount DESC;


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@rrobetti
Copy link
Contributor

@copilot Remember that the goal of the test is to run the same ineficient SQL with and without SQL enhancement enabled in OJP and copare the time it takes, with SQL enhancement it should be faster.

Copilot AI and others added 2 commits January 11, 2026 11:41
…low integration

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ro, jar path config, health checks, and SQL script execution

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
# 4. Verifying identical results and comparing performance
# ===================================================================

- name: Stop default OJP server before SQL Enhancer test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot there is no need to stop the default OJP server, is there? Just start 2 separated ones for the test and make sure you stop those 2 after the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! Removed the unnecessary step to stop the default OJP server. The test already manages its own server lifecycle - it starts two separate OJP servers on random ports in @BeforeAll and stops them in @afterall teardown. Fixed in commit 50afbd4.

Copilot AI changed the title [WIP] Add integration test for SQL enhancing functionality Add PostgreSQL integration test for SQL enhancer with dual-server comparison Jan 11, 2026
Copilot AI requested a review from rrobetti January 11, 2026 11:51
… own server lifecycle

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 11, 2026

@copilot Remember that the goal of the test is to run the same ineficient SQL with and without SQL enhancement enabled in OJP and copare the time it takes, with SQL enhancement it should be faster.

Confirmed! The test executes the same inefficient SQL query on both servers (with and without SQL enhancement) and logs the execution time for comparison. The test expects the SQL-enhanced server to execute faster while returning identical results. Performance metrics are logged in the format: "Server 1 (enhanced) = X ms, Server 2 (baseline) = Y ms, Difference = Z%".

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
@rrobetti
Copy link
Contributor

@copilot new test fails locally with error:
/usr/lib/jvm/jdk-22-oracle-x64/bin/java -ea -Dfile.encoding=UTF-8 -Didea.test.cyclic.buffer.size=10238976 -javaagent:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/lib/idea_rt.jar=42171:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/bin -javaagent:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/java/lib/rt/debugger-agent.jar=file:/tmp/capture.props -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Ddebugger.agent.enable.coroutines=true -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /home/rogerio/.m2/repository/org/junit/platform/junit-platform-launcher/1.12.1/junit-platform-launcher-1.12.1.jar:/home/rogerio/.m2/repository/org/junit/vintage/junit-vintage-engine/5.12.1/junit-vintage-engine-5.12.1.jar:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/lib/idea_rt.jar:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/junit/lib/junit5-rt.jar:/home/rogerio/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/junit/lib/junit-rt.jar:/home/rogerio/Projects/OpenJProxy/ojp/ojp-jdbc-driver/target/test-classes:/home/rogerio/Projects/OpenJProxy/ojp/ojp-jdbc-driver/target/classes:/home/rogerio/Projects/OpenJProxy/ojp/ojp-grpc-commons/target/classes:/home/rogerio/.m2/repository/io/grpc/grpc-netty/1.73.0/grpc-netty-1.73.0.jar:/home/rogerio/.m2/repository/io/grpc/grpc-api/1.73.0/grpc-api-1.73.0.jar:/home/rogerio/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.24/animal-sniffer-annotations-1.24.jar:/home/rogerio/.m2/repository/io/netty/netty-codec-http2/4.1.110.Final/netty-codec-http2-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-common/4.1.110.Final/netty-common-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-buffer/4.1.110.Final/netty-buffer-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-transport/4.1.110.Final/netty-transport-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-resolver/4.1.110.Final/netty-resolver-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-codec/4.1.110.Final/netty-codec-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-handler/4.1.110.Final/netty-handler-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-codec-http/4.1.110.Final/netty-codec-http-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/grpc/grpc-core/1.73.0/grpc-core-1.73.0.jar:/home/rogerio/.m2/repository/com/google/code/gson/gson/2.11.0/gson-2.11.0.jar:/home/rogerio/.m2/repository/com/google/android/annotations/4.1.1.4/annotations-4.1.1.4.jar:/home/rogerio/.m2/repository/io/grpc/grpc-context/1.73.0/grpc-context-1.73.0.jar:/home/rogerio/.m2/repository/io/netty/netty-handler-proxy/4.1.110.Final/netty-handler-proxy-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/netty/netty-codec-socks/4.1.110.Final/netty-codec-socks-4.1.110.Final.jar:/home/rogerio/.m2/repository/com/google/guava/guava/33.3.1-android/guava-33.3.1-android.jar:/home/rogerio/.m2/repository/com/google/guava/failureaccess/1.0.2/failureaccess-1.0.2.jar:/home/rogerio/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/home/rogerio/.m2/repository/com/google/j2objc/j2objc-annotations/3.0.0/j2objc-annotations-3.0.0.jar:/home/rogerio/.m2/repository/com/google/errorprone/error_prone_annotations/2.30.0/error_prone_annotations-2.30.0.jar:/home/rogerio/.m2/repository/io/perfmark/perfmark-api/0.27.0/perfmark-api-0.27.0.jar:/home/rogerio/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.110.Final/netty-transport-native-unix-common-4.1.110.Final.jar:/home/rogerio/.m2/repository/io/grpc/grpc-util/1.73.0/grpc-util-1.73.0.jar:/home/rogerio/.m2/repository/io/grpc/grpc-protobuf/1.73.0/grpc-protobuf-1.73.0.jar:/home/rogerio/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/home/rogerio/.m2/repository/com/google/api/grpc/proto-google-common-protos/2.51.0/proto-google-common-protos-2.51.0.jar:/home/rogerio/.m2/repository/io/grpc/grpc-protobuf-lite/1.73.0/grpc-protobuf-lite-1.73.0.jar:/home/rogerio/.m2/repository/io/grpc/grpc-stub/1.73.0/grpc-stub-1.73.0.jar:/home/rogerio/.m2/repository/com/google/protobuf/protobuf-java/3.25.5/protobuf-java-3.25.5.jar:/home/rogerio/.m2/repository/kr/motd/maven/os-maven-plugin/1.7.1/os-maven-plugin-1.7.1.jar:/home/rogerio/.m2/repository/org/apache/maven/maven-plugin-api/3.5.3/maven-plugin-api-3.5.3.jar:/home/rogerio/.m2/repository/org/apache/maven/maven-model/3.5.3/maven-model-3.5.3.jar:/home/rogerio/.m2/repository/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar:/home/rogerio/.m2/repository/org/apache/maven/maven-artifact/3.5.3/maven-artifact-3.5.3.jar:/home/rogerio/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.3/org.eclipse.sisu.plexus-0.3.3.jar:/home/rogerio/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar:/home/rogerio/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/rogerio/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/rogerio/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.3/org.eclipse.sisu.inject-0.3.3.jar:/home/rogerio/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar:/home/rogerio/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.5.2/plexus-classworlds-2.5.2.jar:/home/rogerio/.m2/repository/org/codehaus/plexus/plexus-utils/3.1.0/plexus-utils-3.1.0.jar:/home/rogerio/.m2/repository/org/slf4j/slf4j-api/2.0.17/slf4j-api-2.0.17.jar:/home/rogerio/.m2/repository/org/slf4j/slf4j-simple/2.0.17/slf4j-simple-2.0.17.jar:/home/rogerio/.m2/repository/jakarta/transaction/jakarta.transaction-api/2.0.1/jakarta.transaction-api-2.0.1.jar:/home/rogerio/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/home/rogerio/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/rogerio/.m2/repository/org/junit/jupiter/junit-jupiter/5.12.1/junit-jupiter-5.12.1.jar:/home/rogerio/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.12.1/junit-jupiter-api-5.12.1.jar:/home/rogerio/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/home/rogerio/.m2/repository/org/junit/platform/junit-platform-commons/1.12.1/junit-platform-commons-1.12.1.jar:/home/rogerio/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.12.1/junit-jupiter-engine-5.12.1.jar:/home/rogerio/.m2/repository/org/junit/platform/junit-platform-engine/1.12.1/junit-platform-engine-1.12.1.jar:/home/rogerio/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.12.1/junit-jupiter-params-5.12.1.jar:/home/rogerio/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/home/rogerio/.m2/repository/com/zaxxer/HikariCP/7.0.1/HikariCP-7.0.1.jar:/home/rogerio/.m2/repository/com/atomikos/transactions-jta/6.0.0/transactions-jta-6.0.0-jakarta.jar:/home/rogerio/.m2/repository/com/atomikos/transactions-api/6.0.0/transactions-api-6.0.0.jar:/home/rogerio/.m2/repository/com/atomikos/transactions/6.0.0/transactions-6.0.0.jar:/home/rogerio/.m2/repository/com/atomikos/atomikos-util/6.0.0/atomikos-util-6.0.0.jar:/home/rogerio/.m2/repository/com/atomikos/transactions-jdbc/6.0.0/transactions-jdbc-6.0.0-jakarta.jar:/home/rogerio/.m2/repository/org/postgresql/postgresql/42.7.5/postgresql-42.7.5.jar:/home/rogerio/.m2/repository/org/checkerframework/checker-qual/3.48.3/checker-qual-3.48.3.jar:/home/rogerio/.m2/repository/com/microsoft/sqlserver/mssql-jdbc/12.8.2.jre11/mssql-jdbc-12.8.2.jre11.jar:/home/rogerio/.m2/repository/org/testcontainers/mssqlserver/1.20.4/mssqlserver-1.20.4.jar:/home/rogerio/.m2/repository/org/testcontainers/jdbc/1.20.4/jdbc-1.20.4.jar:/home/rogerio/.m2/repository/org/testcontainers/database-commons/1.20.4/database-commons-1.20.4.jar:/home/rogerio/.m2/repository/org/testcontainers/testcontainers/1.20.4/testcontainers-1.20.4.jar:/home/rogerio/.m2/repository/org/apache/commons/commons-compress/1.24.0/commons-compress-1.24.0.jar:/home/rogerio/.m2/repository/org/rnorth/duct-tape/duct-tape/1.0.8/duct-tape-1.0.8.jar:/home/rogerio/.m2/repository/org/jetbrains/annotations/17.0.0/annotations-17.0.0.jar:/home/rogerio/.m2/repository/com/github/docker-java/docker-java-api/3.4.0/docker-java-api-3.4.0.jar:/home/rogerio/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.10.3/jackson-annotations-2.10.3.jar:/home/rogerio/.m2/repository/com/github/docker-java/docker-java-transport-zerodep/3.4.0/docker-java-transport-zerodep-3.4.0.jar:/home/rogerio/.m2/repository/com/github/docker-java/docker-java-transport/3.4.0/docker-java-transport-3.4.0.jar:/home/rogerio/.m2/repository/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar:/home/rogerio/.m2/repository/org/projectlombok/lombok/1.18.38/lombok-1.18.38.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - Setting up PostgreSQL SQL Enhancer Integration Test
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - Allocated ports: Server 1 (SQL enhancer enabled) = 36473, Server 2 (baseline) = 43041
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - Setting up test data in PostgreSQL
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - Stopping OJP servers
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - OJP servers stopped

Test ignored.

java.lang.IllegalArgumentException: Invalid OJP URL format. Expected: jdbc:ojp[host:port]_actual_jdbc_url

at org.openjproxy.grpc.client.MultinodeUrlParser.parseServerEndpoints(MultinodeUrlParser.java:133)
at org.openjproxy.grpc.client.MultinodeUrlParser.getOrCreateStatementService(MultinodeUrlParser.java:63)
at org.openjproxy.jdbc.Driver.connect(Driver.java:58)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:682)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:230)
at openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest.setupTestData(PostgresSqlEnhancerIntegrationTest.java:151)
at openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest.setup(PostgresSqlEnhancerIntegrationTest.java:88)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)

Process finished with exit code 255

…eption

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 11, 2026

@copilot new test fails locally with error:
/usr/lib/jvm/jdk-22-oracle-x64/bin/java -ea -Dfile.encoding=UTF-8 -Didea.test.cyclic.buffer.size=10238976 -javaagent:/home/rogerio/.local/share/JetBrains/T...

Fixed in commit 40ae485. The issue was that the OJP driver was intercepting the direct PostgreSQL connection during test data setup. The test now creates a PostgreSQL driver instance directly (new org.postgresql.Driver().connect()) instead of using DriverManager.getConnection(), which bypasses the driver selection mechanism and prevents the OJP driver from being invoked for the setup connection.

Copilot AI and others added 2 commits January 11, 2026 12:16
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
@rrobetti
Copy link
Contributor

@copilot failing for a different reason now:
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - OJP servers stopped

Test ignored.

org.postgresql.util.PSQLException: ERROR: relation "customers" does not exist

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2733)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2420)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:372)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:517)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:434)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:356)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:341)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:317)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:312)
at openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest.setupTestData(PostgresSqlEnhancerIntegrationTest.java:177)
at openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest.setup(PostgresSqlEnhancerIntegrationTest.java:93)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 11, 2026

@copilot failing for a different reason now:
[main] INFO openjproxy.jdbc.PostgresSqlEnhancerIntegrationTest - OJP servers stopped

...

Fixed in commit dd06c2a. The issue was with SQL script parsing - the simple semicolon split was breaking multi-line INSERT statements with generate_series(). Now using a regex pattern ";\\s*(?=\\n|$)" to split only at semicolons that are followed by whitespace and end-of-line, which properly preserves multi-line SQL statements. Added error logging to help diagnose any future SQL execution issues.

Copilot AI and others added 3 commits January 11, 2026 12:46
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…maintainability

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ting

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copilot AI and others added 14 commits February 3, 2026 10:25
…QL optimization

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ancer-issue

Fix SQL Enhancer - Register Comprehensive Calcite Optimization Rules
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…t-setting

[WIP] Fix incorrect SQL generation for PostgreSQL dialect in Calcite
…pler query

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
- Confirmed SQL enhancer is disabled by default (DEFAULT_SQL_ENHANCER_ENABLED = false)
- Added prominent warnings to all documentation stating Calcite is experimental
- Clarified known limitations with PostgreSQL, MySQL, Oracle, SQL Server
- Noted Calcite works better with big data systems (Hive, Drill, Flink, BigQuery, etc.)
- Strongly discourage production use in current state

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
- Updated 5 analysis/implementation documents with experimental warnings
- documents/analysis/sql_enhancer/SQL_ENHANCER_AND_SCHEMA_LOADER.md
- documents/analysis/sql_enhancer/SQL_ENHANCER_ENGINE_ANALYSIS.md
- documents/analysis/sql_enhancer/SQL_ENHANCER_GAP_ANALYSIS_SUMMARY.md
- documents/implementation_plans/SCHEMA_LOADER_IMPLEMENTATION_PLAN.md
- documents/analysis/CALCITE_QUERY_COMPLEXITY_FOR_SLOW_QUERY_SEGREGATION_ANALYSIS.md

All Calcite-related documentation now includes prominent warnings about experimental status and limitations with traditional JDBC databases.

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ancer-test

Document SQL enhancer type system limitations, add experimental warnings, and improve test observability
@rrobetti
Copy link
Contributor

rrobetti commented Feb 8, 2026

@copilot [INFO] Results:
[INFO]
Error: Errors:
Error: PostgresSqlEnhancerIntegrationTest.setup:106->setupTestData:123 » PSQL Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
[INFO]
Error: Tests run: 921, Failures: 0, Errors: 1, Skipped: 739

…se is not running

The integration test was failing in CI environments where PostgreSQL is not available with "Connection refused" errors. Added isPostgreSQLAvailable() method to check database connectivity before running tests. When PostgreSQL is not accessible, the test now skips gracefully with an informative log message instead of failing. This allows the test to run only in environments where PostgreSQL is properly configured (like the postgres-test CI job) while not breaking builds in other contexts.

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot [INFO] Results:
[INFO]
Error: Errors:
...

Fixed in commit 58eab35. Added PostgreSQL availability check to the test setup. The test now checks if PostgreSQL is accessible before attempting to run, and skips gracefully when the database is not available (common in CI environments where the postgres-test job hasn't started PostgreSQL). This prevents "Connection refused" errors while still allowing the test to run in environments where PostgreSQL is properly configured.

@rrobetti
Copy link
Contributor

rrobetti commented Feb 8, 2026

@copilot no, your last fix is not acceptable, revert it. Disable the test only enabling it when other postgres tests are enabled.

… of custom availability check

Reverted the PostgreSQL availability check approach and instead aligned with other PostgreSQL tests by using the standard enablePostgresTests system property. The test now:
- Defaults to disabled (enablePostgresTests=false)
- Skips gracefully with assumeFalse when disabled
- Runs only when explicitly enabled with -DenablePostgresTests=true
- Uses consistent messaging with other PostgreSQL tests

This prevents the test from running in environments without PostgreSQL while maintaining consistency with existing test patterns.

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot no, your last fix is not acceptable, revert it. Disable the test only enabling it when other postgres tests are enabled.

Reverted the PostgreSQL availability check in commit 2f56452. The test now uses the standard enablePostgresTests property (defaulting to false) consistent with other PostgreSQL tests in the codebase. The test skips gracefully with assumeFalse when disabled and runs only when explicitly enabled with -DenablePostgresTests=true.

@rrobetti
Copy link
Contributor

rrobetti commented Feb 8, 2026

@copilot test is not correctly disabled, setup still running

Error: Errors:
Error: PostgresSqlEnhancerIntegrationTest.setup:101->setupTestData:118 » PSQL Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
[INFO]
Error: Tests run: 921, Failures: 0, Errors: 1, Skipped: 739

… PostgreSQL connection attempts

The setup() method was attempting to connect to PostgreSQL and setup test data even when enablePostgresTests=false, causing "Connection refused" errors in environments without PostgreSQL. Added check at the beginning of setup() to return early when the test is disabled, preventing any database connection attempts. This ensures the test is completely skipped (including all setup code) when disabled, consistent with other PostgreSQL tests.

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot test is not correctly disabled, setup still running

Error: Errors:
...

Fixed in commit 21229f0. Added early return at the beginning of the setup() method when enablePostgresTests is false, preventing all database connection attempts. The test now properly skips the entire setup phase (including setupTestData()) when disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants