google / google/googlesql

buildStatement of a ResolvedStatement doesn't work when there is a tree of catalogs

Open
#34 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.6k
Forks
260
PR merge metrics
No merged PRs in 30d

Description

I am trying out a very simple case where I build the sql statement again after I got the resolvedStatement. Below some test code:
```
public class Main {

private static String SQL = "SELECT * FROM test_dataset.test_table;";

public static void main(String[] args) {
SimpleCatalog catalog = new SimpleCatalog("catalog");
SimpleCatalog datasetCatalog = new SimpleCatalog("test_dataset");
SimpleTable simpleTable = new SimpleTable("test_table");
simpleTable.addSimpleColumn("colA", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_STRING));
simpleTable.addSimpleColumn("colB", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_STRING));
simpleTable.addSimpleColumn("colC", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_STRING));
datasetCatalog.addSimpleTable(simpleTable);
catalog.addSimpleCatalog(datasetCatalog);

AnalyzerOptions options = new AnalyzerOptions();
ResolvedNodes.ResolvedStatement resolvedStatement = Analyzer.analyzeStatement(SQL, options, catalog);

String statementString = Analyzer.buildStatement(resolvedStatement, catalog);

System.out.println(statementString);
}
}
```

I get the following error:
```
FATAL statusor.cc : 38 : Attempting to fetch value instead of handling error NOT_FOUND: Table not found: test_table not found in catalog catalog
```

When I use datasetCatalog in the Analyzer.buildStatement(), I don't get an error but obviously the dataset info is not present.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.