How to read where clause columns
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
I am using the ZetaSql analyzeStatement and reading the where clause column names from the query after the analysis like the following.
String query = "Select count(*) from table1 where column1 = 'ABC' and column2 = 'abc' and column3 = 'zxc'";
ResolvedStatement resolvedStatement = analyzer.analyzeStatement(query);
Set columnNameSet = new HashSet<>();
resolvedStatement.accept(new ResolvedNodes.Visitor() {
@Override
public void visit(ResolvedNodes.ResolvedColumnRef node) {
columnNameSet.add(node.getColumn().getName());
}
});
Above callback method is giving me the where clause column name like following.
columnNameSet = [column1, column2, column3]
Is there a better way to read the where clause column names?
Contributor guide
Research direction
Start with the issue's analyzeStatement call and the ResolvedNodes.Visitor implementation, especially visit(ResolvedNodes.ResolvedColumnRef), to understand how column references are collected. Done means documenting whether this is the supported way to identify WHERE-clause columns or pointing to a better analyzer API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- api, databases
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100