GSP Java v3.x to v4 Migration Guide¶
Version: 4.0 Last Updated: January 2026 Applies to: GSP Java SQL Parser Library
Table of Contents¶
- Executive Summary
- Quick Start
- Switching Between Resolvers
- Why TSQLResolver2 is Better
- Deprecated APIs Reference
- New APIs Reference
- API Comparison and Migration Table
- Class Location Changes
- Code Migration Examples
- Best Practices for Migration
- Known Limitations and Considerations
- Troubleshooting
- Support and Resources
1. Executive Summary¶
Purpose of the Upgrade¶
GSP Java v4 introduces TSQLResolver2, a completely redesigned semantic analysis engine that replaces the existing TSQLResolver. The primary focus is on name resolution - building correct relationships between columns and tables used in SQL statements.
Backward Compatibility¶
Good News: No immediate code changes are required for basic usage.
TSQLResolver2 automatically synchronizes resolution data back to existing APIs (like TTable.getLinkedColumns() and TObjectName.getSourceTable()), ensuring your existing code continues to work without modification.
Deprecation Timeline¶
Important: APIs marked as deprecated will be removed after 2026/12/31.
Plan your migration to new APIs before this deadline to ensure continued compatibility.
Production Readiness Warning¶
Caution: Do NOT use v4 in production environments without thorough testing.
Due to the significant refactoring, not all SQL syntax variations have been fully tested. Carefully validate your specific SQL patterns before deploying to production.
2. Quick Start¶
For Users Who Just Want v4 to Work¶
If you're currently using GSP Java v3.x and want to upgrade to v4 with minimal changes:
- Update your dependency to GSP Java v4.x
- Run your existing code - it should work without modifications
- Test thoroughly - verify output matches your expectations
- Monitor deprecation warnings - plan to update deprecated API usage before 2026/12/31
For Users Who Want to Leverage New Features¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
3. Switching Between Resolvers¶
3.1 Global Level Configuration (TBaseType)¶
Control the default resolver for all parser instances:
1 2 3 4 5 | |
Important Notes:
- TBaseType.isEnableResolver2() returns true by default in v4
- You cannot enable both resolvers simultaneously - an IllegalStateException will be thrown
- To switch resolvers, disable one before enabling the other:
1 2 3 | |
3.2 Parser Level Configuration (TGSqlParser)¶
Override global settings for individual parser instances:
1 2 | |
EResolverType Values:
| Value | Description |
|---|---|
EResolverType.DEFAULT |
Use global TBaseType setting (resolution order: RESOLVER2 > RESOLVER > NONE) |
EResolverType.RESOLVER |
Force legacy TSQLResolver |
EResolverType.RESOLVER2 |
Force new TSQLResolver2 |
EResolverType.NONE |
Disable resolution entirely |
3.3 Configuration Precedence¶
- Instance-level
setResolverType()takes highest precedence - If
DEFAULT, falls back to globalTBaseTypesettings - If both disabled in TBaseType, no resolution is performed
4. Why TSQLResolver2 is Better¶
TSQLResolver2 provides significant improvements over the legacy resolver:
4.1 Namespace-based Architecture¶
Uses a proper namespace hierarchy for accurate column resolution:
- GlobalScope → SelectScope → FromScope
- TableNamespace, SubqueryNamespace, CTENamespace, UnionNamespace
4.2 Better Subquery and CTE Handling¶
Correctly traces columns through nested subqueries and CTEs:
1 2 3 | |
4.3 Confidence Scoring¶
Provides confidence scores [0.0, 1.0] for resolution results:
1 2 | |
4.4 Evidence-based Resolution¶
Tracks evidence explaining how each column was resolved:
1 2 | |
4.5 Physical Table Tracing¶
Traces columns back to their final physical table through subqueries/CTEs:
| Method | Returns |
|---|---|
column.getSourceTable() |
Immediate source (subquery, CTE, or physical table) |
source.getFinalTable() |
Final physical table after tracing |
source.getAllFinalTables() |
All final tables (for UNION queries) |
4.6 Improved Star Column Handling¶
Better expansion and tracking of SELECT * columns with proper scope awareness.
4.7 Union Query Support¶
Correctly handles columns from UNION queries with multiple source tables:
1 | |
4.8 Ambiguous Column Detection¶
Better detection and handling of ambiguous column references:
1 2 3 | |
5. Deprecated APIs Reference¶
The following APIs are deprecated and will be removed after 2026/12/31:
5.1 TTable Class¶
| Deprecated API | Location | Deprecated Since | Removal Date |
|---|---|---|---|
getLinkedColumns() |
TTable.java:1405-1417 | v3.3.1.0 | 2026/12/31 |
getAttributes() |
TTable.java:43-53 | v3.3.1.0 | 2026/12/31 |
5.2 TCustomSqlStatement Class¶
| Deprecated API | Location | Deprecated Since | Removal Date |
|---|---|---|---|
getAttributes() |
TCustomSqlStatement.java:387-399 | Implicit | 2026/12/31 |
5.3 TObjectName Class¶
| Deprecated API | Location | Deprecated Since | Removal Date |
|---|---|---|---|
getSourceAttributeNode() |
TObjectName.java:108-110 | v3.4.0.5 | 2026/12/31 |
setSourceAttributeNode() |
TObjectName.java:92-98 | v3.4.0.5 | 2026/12/31 |
getCandidateAttributeNodes() |
TObjectName.java:456-461 | Implicit | 2026/12/31 |
5.4 TResultColumn Class¶
| Deprecated API | Location | Deprecated Since | Removal Date |
|---|---|---|---|
getAttributesFromUpLevelReferenceToStarColumn() |
TResultColumn.java:46-63 | Implicit | 2026/12/31 |
5.5 APIs NOT Deprecated (Still Valid)¶
The following APIs remain valid and work with both resolvers:
| API | Class | Notes |
|---|---|---|
getSourceTable() |
TObjectName | Enhanced to work with both resolvers; returns null for ambiguous columns in RESOLVER2 |
getSourceColumn() |
TObjectName | Still used by both resolvers |
getLinkedColumnDef() |
TObjectName | Still valid for DDL statements |
6. New APIs Reference¶
6.1 TObjectName New Methods¶
Package: gudusoft.gsqlparser.nodes.TObjectName
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
6.2 ColumnSource Class¶
Package: gudusoft.gsqlparser.resolver2.model.ColumnSource
This is the primary class for accessing detailed resolution information:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
6.3 ResolutionResult Class¶
Package: gudusoft.gsqlparser.resolver2.model.ResolutionResult
Container for resolution outcomes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
6.4 IResolutionResult Interface¶
Package: gudusoft.gsqlparser.resolver2.result.IResolutionResult
Statement-level query interface for resolution results:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
6.5 TSQLResolver2 Main Class¶
Package: gudusoft.gsqlparser.resolver2.TSQLResolver2
Main entry point for the new resolver:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
6.6 TSQLResolverConfig Class¶
Package: gudusoft.gsqlparser.resolver2.TSQLResolverConfig
Configuration options for TSQLResolver2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
7. API Comparison and Migration Table¶
7.1 Complete Migration Reference¶
| Use Case | Old API (v3.x) | New API (v4) | Notes |
|---|---|---|---|
| Get columns linked to a table | table.getLinkedColumns() |
Iterate resolver.getResult().getColumnsForTable(stmt, table) |
Use IResolutionResult interface |
| Get table attributes | table.getAttributes() |
Use namespace classes: TableNamespace.getAllColumnSources() |
Direct namespace access |
| Get source table for column | column.getSourceTable() |
column.getSourceTable() (still works) or column.getColumnSource().getSourceNamespace().getSourceTable() |
Both work |
| Get final physical table | N/A (limited support) | column.getColumnSource().getFinalTable() |
New capability |
| Get all final tables (UNION) | N/A | column.getColumnSource().getAllFinalTables() |
New capability |
| Check resolution confidence | N/A | column.getColumnSource().getConfidence() |
New capability |
| Get resolution evidence | N/A | column.getColumnSource().getEvidence() |
New capability |
| Handle ambiguous columns | column.getCandidateAttributeNodes() |
column.getColumnSource().getCandidateTables() |
Simplified API |
| Get source attribute node | column.getSourceAttributeNode() |
column.getResolution().getColumnSource() |
Complete replacement |
| Get CTE columns | cteTable.getAttributes() |
CTENamespace.getAllColumnSources() |
Direct namespace access |
| Get unresolved columns | Manual tracking | resolver.getResult().getOrphanColumns(stmt) |
New capability |
| Get all table names | Manual iteration | resolver.getResult().getAllTableNames() |
New capability |
| Get resolution statistics | N/A | resolver.getStatistics() |
New capability |
7.2 Deprecated Method Replacement Summary¶
| Deprecated Method | Direct Replacement |
|---|---|
TTable.getLinkedColumns() |
IResolutionResult.getColumnsForTable(stmt, table) |
TTable.getAttributes() |
INamespace.getAllColumnSources() |
TCustomSqlStatement.getAttributes() |
Iterate through resolved columns via IResolutionResult |
TObjectName.getSourceAttributeNode() |
TObjectName.getColumnSource() |
TObjectName.getCandidateAttributeNodes() |
TObjectName.getColumnSource().getCandidateTables() |
TResultColumn.getAttributesFromUpLevelReferenceToStarColumn() |
Integrated into TSQLResolver2's star column handling |
8. Class Location Changes¶
| Class | Old Package (v3.x) | New Package (v4) |
|---|---|---|
TGetTableColumn |
demos.gettablecolumns |
gudusoft.gsqlparser.util |
Update your import statements:
1 2 3 4 5 | |
9. Code Migration Examples¶
9.1 Example 1: Iterating Through Table Columns¶
Old Way (v3.x):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
New Way (v4):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
9.2 Example 2: Tracing Column Through Subquery¶
New Capability in v4:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
9.3 Example 3: Handling Ambiguous Columns¶
Old Way (v3.x):
1 2 3 4 5 | |
New Way (v4):
1 2 3 4 5 6 7 8 9 10 | |
9.4 Example 4: Using TGetTableColumn (Works with Both Resolvers)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
9.5 Example 5: Supporting Both Resolvers During Transition¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
10. Best Practices for Migration¶
10.1 Migration Strategy¶
Phase 1: Validation (Recommended Duration: 2-4 weeks) 1. Update dependency to GSP Java v4 2. Run existing code without modifications 3. Compare output with v3.x behavior 4. Document any differences
Phase 2: Testing (Recommended Duration: 2-4 weeks)
1. Create comprehensive tests comparing both resolvers
2. Enable debug logging: TBaseType.DUMP_RESOLVER_LOG_TO_CONSOLE = true
3. Test with your specific SQL patterns
4. Identify any behavioral changes
Phase 3: API Migration (Before 2026/12/31) 1. Update deprecated API calls to new APIs 2. Remove deprecation warnings 3. Leverage new capabilities where beneficial
10.2 Code Migration Recommendations¶
-
Start with Backward Compatible APIs: Since TSQLResolver2 syncs data back to existing APIs, your existing code should work without changes. Verify this first.
-
Gradual Migration: Start by testing with
EResolverType.DEFAULT(uses TSQLResolver2), then gradually update code to use new APIs. -
Leverage New Capabilities: Take advantage of new features like
getFinalTable()for data lineage and confidence scoring. -
Update Tests: Ensure your test suite covers both resolvers during the transition period.
-
Monitor Deprecation Warnings: If your IDE shows deprecation warnings, prioritize updating those usages.
10.3 Configuration Recommendations¶
For Legacy Compatibility:
1 2 3 4 | |
For New Code (No Legacy Dependencies):
1 2 3 | |
For Vendor-Specific Behavior:
1 2 3 | |
11. Known Limitations and Considerations¶
11.1 SQL Syntax Coverage¶
Due to the significant refactoring, not all SQL syntax variations have been fully tested. If you encounter unexpected behavior:
- Enable debug logging:
TBaseType.DUMP_RESOLVER_LOG_TO_CONSOLE = true - Compare with old resolver:
parser.setResolverType(EResolverType.RESOLVER) - Report issues with reproducible SQL examples
11.2 Performance Considerations¶
TSQLResolver2 may have different performance characteristics:
- Three-phase resolution: Scope building, initial resolution, iterative enhancement
- Namespace hierarchy: More sophisticated but potentially slower
- Iterative passes: Complex queries may require multiple passes
Optimization Tips:
- Profile specific queries if performance is critical
- Use TSQLResolverConfig.createStandalone() to disable legacy sync if not needed
- Consider EResolverType.RESOLVER for specific performance-critical cases
11.3 Metadata Requirements¶
Some advanced resolution features require providing database metadata:
1 2 3 | |
Without metadata, the resolver relies on inference which may have lower confidence.
11.4 Ambiguous Column Handling¶
TSQLResolver2 handles ambiguous columns differently:
TObjectName.getSourceTable()returnsnullfor ambiguous columns (except star columns)- Use
ColumnSource.isAmbiguous()to check - Use
ColumnSource.getCandidateTables()to get all possibilities
11.5 Star Column Special Cases¶
Star columns (SELECT *) receive special handling:
getSourceTable()preserves Phase 1 resolution for star columns- Use resolver's star column expansion for detailed tracking
ColumnSource.getAllFinalTables()returns all contributing tables
12. Troubleshooting¶
12.1 Common Issues and Solutions¶
| Issue | Possible Cause | Solution |
|---|---|---|
| Column resolution differs from v3.x | TSQLResolver2 resolves ambiguous cases differently | Review resolution via getEvidence(), provide metadata via TSQLEnv |
| Missing table/column relationships | Star column expansion handling changed | Enable showCTE option, verify subquery handling |
| Performance regression | TSQLResolver2 architecture overhead | Profile specific queries, consider resolver switching |
| Deprecation warnings | Using deprecated APIs | Update to new APIs per migration table |
getSourceTable() returns null |
Column is ambiguous in RESOLVER2 | Check isAmbiguous(), use getCandidateTables() |
| Class not found: TGetTableColumn | Package location changed | Update import to gudusoft.gsqlparser.util.TGetTableColumn |
12.2 Debug Logging¶
Enable detailed resolution logging:
1 | |
This outputs: - Scope tree construction - Column resolution attempts - Namespace lookups - Star column expansion - Iterative pass progress
12.3 Comparing Resolvers¶
To compare output between resolvers:
1 2 3 4 5 6 7 8 9 | |
13. Support and Resources¶
13.1 Documentation¶
- API Reference: See JavaDoc for
gudusoft.gsqlparser.resolver2package - Developer Guide:
resolver2/TSQLResolver2_Developer_Guide.md
13.2 Reporting Issues¶
When reporting issues, please include:
1. GSP Java version
2. Database vendor (EDbVendor)
3. SQL statement causing the issue
4. Expected vs actual behavior
5. Debug log output if available
13.3 Version Compatibility¶
| GSP Java Version | Default Resolver | TSQLResolver2 Status |
|---|---|---|
| v3.x | TSQLResolver | Not available |
| v4.0 | TSQLResolver2 | Production (with testing) |
13.4 Deprecation Schedule¶
| Date | Event |
|---|---|
| v4.0 Release | TSQLResolver2 becomes default |
| 2026/12/31 | Deprecated APIs removed |
Appendix A: Complete New API Package Structure¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Appendix B: Quick Reference Card¶
Resolver Configuration¶
1 2 3 4 5 6 7 8 | |
Key New APIs¶
1 2 3 4 5 6 7 8 9 10 11 | |
Deprecated API Quick Migration¶
| Old | New |
|---|---|
table.getLinkedColumns() |
result.getColumnsForTable(stmt, table) |
table.getAttributes() |
namespace.getAllColumnSources() |
column.getSourceAttributeNode() |
column.getColumnSource() |
column.getCandidateAttributeNodes() |
source.getCandidateTables() |
This migration guide is maintained by the GSP Java team. For the latest updates, refer to the official documentation.