{"record":{"id":"ebc45006bec5374b","repo":"apache/seatunnel","slug":"failed-getting-synonym-s","errorCode":null,"errorMessage":"Failed getting SYNONYM %s","messagePattern":"Failed getting SYNONYM (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/saphana/SapHanaCatalog.java","lineNumber":232,"sourceCode":"        } else {\n            dbUrl = getUrlFromDatabaseName(defaultDatabase);\n        }\n        Connection conn = getConnection(dbUrl);\n        TablePath originalTablePath = tablePath;\n        if (listSynonym(tablePath.getDatabaseName()).contains(tablePath.getTableName())) {\n            String sql =\n                    String.format(\n                            \"SELECT SYNONYM_NAME, SCHEMA_NAME, OBJECT_NAME, OBJECT_SCHEMA  FROM SYNONYMS  WHERE SCHEMA_NAME = '%s' AND SYNONYM_NAME = '%s' \",\n                            tablePath.getDatabaseName(), tablePath.getTableName());\n            try (PreparedStatement statement = conn.prepareStatement(sql);\n                    final ResultSet resultSet = statement.executeQuery()) {\n                while (resultSet.next()) {\n                    final String refDatabaseName = resultSet.getString(\"OBJECT_SCHEMA\");\n                    final String refTableName = resultSet.getString(\"OBJECT_NAME\");\n                    tablePath = TablePath.of(refDatabaseName, refTableName);\n                }\n            } catch (Exception e) {\n                throw new CatalogException(\n                        String.format(\"Failed getting SYNONYM %s\", tablePath.getFullName()), e);\n            }\n        }\n        try {\n            DatabaseMetaData metaData = conn.getMetaData();\n            Optional<PrimaryKey> primaryKey = getPrimaryKey(metaData, tablePath);\n            List<ConstraintKey> constraintKeys = getConstraintKeys(metaData, tablePath);\n            try (PreparedStatement ps = conn.prepareStatement(getSelectColumnsSql(tablePath));\n                    ResultSet resultSet = ps.executeQuery()) {\n\n                TableSchema.Builder builder = TableSchema.builder();\n                buildColumnsWithErrorCheck(tablePath, resultSet, builder);\n                // add primary key\n                primaryKey.ifPresent(builder::primaryKey);\n                // add constraint key\n                constraintKeys.forEach(builder::constraintKey);\n                TableIdentifier tableIdentifier = getTableIdentifier(originalTablePath);\n                return CatalogTable.of(","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/saphana/SapHanaCatalog.java#L214-L250","documentation":"When the requested table is actually a SAP HANA SYNONYM, SapHanaCatalog.getTable() resolves the real target by querying the SYNONYMS system view and rewriting the TablePath to the referenced OBJECT_SCHEMA/OBJECT_NAME. If that lookup fails for any reason, it throws a CatalogException with 'Failed getting SYNONYM <fullName>'. This is a wrapper exception; the underlying cause (SQL error, connection problem, unexpected result set) is attached.","triggerScenarios":"The table name is in listSynonym(databaseName) but the SYNONYMS system-view query (prepared from a string-formatted SQL with schema and synonym name interpolated) throws — e.g. synonym names containing quote characters breaking the SQL, connection lost, or permission denied reading SYNONYMS.","commonSituations":"Synonyms with quotes/special characters in schema or name; user lacks privilege on the SYNONYMS view for the schema; dangling synonyms whose OBJECT_SCHEMA/OBJECT_NAME rows cannot be read; concurrent synonym redefinition.","solutions":["Inspect the cause chain to find the actual SQL/connection error.","Check that the connecting user can SELECT from the SYNONYMS system view for that schema.","Manually run the SYNONYMS query in HANA SQL console with the same SCHEMA_NAME/SYNONYM_NAME to reproduce.","Avoid special quote characters in schema/synonym identifiers, or fix naming to unquoted-safe identifiers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// java\n// confirm the synonym is resolvable before getTable\nList<String> synonyms = catalog.listSynonym(tablePath.getDatabaseName());\nboolean isSynonym = synonyms.contains(tablePath.getTableName());","typeGuard":null,"tryCatchPattern":"// java\ntry {\n    CatalogTable t = catalog.getTable(tablePath);\n} catch (CatalogException e) {\n    if (e.getMessage().startsWith(\"Failed getting SYNONYM\")) {\n        LOG.error(\"synonym resolution failed\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Grant the connecting user SELECT on the SYNONYMS system view.","Avoid quote characters in schema/synonym identifiers.","Resolve dangling synonyms in HANA before running catalog reads."],"tags":["sap-hana","synonym","catalog","sql"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}