3 ms·
I wonder if this is a topical thread to check if anyone is aware of a Java based solution to parse a CREATE VIEW statement to get a mapping between the view col
by noisy_boy 4y ago
I wonder if this is a topical thread to check if anyone is aware of a Java based solution to parse a CREATE VIEW statement to get a mapping between the view columns and the corresponding source table columns. I checked out jsqlparser[0] and it does produce an AST which can be parsed using the visitor-pattern[1] but was wondering if there is a more "out-of-the-box" solution involving less work. Due to various reasons, querying the database information schema is not an option I can pursue.
[0]: https://github.com/JSQLParser/JSqlParser https://github.com/JSQLParser/JSqlParser
[1]: https://en.wikipedia.org/wiki/Visitor_pattern https://en.wikipedia.org/wiki/Visitor_pattern
- benjiweber 4y agoWhat do you mean by a mapping with a source table columns? The data columns in the view could come from 0 to n source tables. Entirely synthetic, transformed, combined data from multiple tables etc.
- noisy_boy 4y agoTrue - I mean the view columns that _are_ from actual tables. Could be straight up table columns as is or may be part of function like max(a.abcd) where a is an alias to table xyz
- gavinray 4y agoApache Calcite can do this, though it's not a beginner-friendly task: https://calcite.apache.org/ https://calcite.apache.org/