This repo provides a script 'cv2sql' which converts graphical HANA Calculation Views to SQL. Each node is converted to a Common Table Expression (CTE) which is supported in most databases.
It is tested in both HANA and Databricks. With the option -d you can omit the specific HANA syntax regarding quotes around objects/fields.
The following node types are currently supported and tested:
- Projection
- Join
- Non Equi Join
- Aggregation
- Union
- Window Function
- Rank
Usage: cv2sql [-h] (-v file | -p path) [-t] [-d]
Options:
-h, --help Show this help message and exit
-v file Convert a specific calculationview to SQL
-p path Convert all files with .hdbcalculationview extention
-t Generate a test query
-d Disable HANA double qoutes around object/field names
When the -t option is provided, a minus query is generated in both directions to be able to test if results between the original calculation view and the generated SQL are the same.
The sub repo in the tests folder is a HANA Cloud repository with 2 custom tables and a set of calculation views. Each node type has its own specific test model. There is also a model with the combination of all supported node types.
If you encounter any failed conversion, please send in the calculation view and I can have a look to see if I can add it. Please reach out to cv2sql@nsltech.nl
Some node types are not yet supported:
- Minus
- Intersect
- Table Function
Other topics:
- Parameters