Parser hdbtable - SAP-archive/xsk GitHub Wiki

Parser for hdbtable

The information on how to develop the design-time data-persistence model for an XSK application using the HDBTable syntax

Reference

  • SAP Help

https://help.sap.com/viewer/cc2b23beaa3344aebffa2f6e717df049/2.0.03/en-US/89cbf999e6004be3a5324b8f9ef0c53f.html

  • Sample Hana XS Classic syntax:
table.schemaName = "MYSCHEMA";
table.tableType = COLUMNSTORE;
table.columns = [
	{name = "Col1"; sqlType = VARCHAR; nullable = false; length = 20; comment = "dummy comment";},
	{name = "Col2"; sqlType = INTEGER; nullable = false;},
	{name = "Col3"; sqlType = NVARCHAR; nullable = true; length = 20; defaultValue = "Defaultvalue";},
	{name = "Col4"; sqlType = DECIMAL; nullable = false; precision = 2; scale = 3;}];
table.indexes =  [
	{name = "MYINDEX1"; unique = true; indexColumns = ["Col2"];},
	{name = "MYINDEX2"; unique = true; indexColumns = ["Col1", "Col4"];}];
table.primaryKey.pkcolumns = ["Col1", "Col2"];
  • Sample Hana XS Advanced syntax
COLUMN TABLE "MYSCHEMA::MYTABLE" ( 
   "ID" INTEGER DEFAULT 555, "NAME" NVARCHAR(256),
   "ACTIVE" TINYINT,
   "COUNTRY" NVARCHAR(256),
   PRIMARY KEY ("ID") )
  • Parser specific details

Parser do not allow duplicate properties.

The order of the table's properties, as well as column's and index's properties is not taken into account when table definition is parsed. Exception will be thrown if a property is defined more than once in the *.hdbtable file. Also, additional exception will be thrown in case a mandatory field is missing.

  • Sample

https://github.com/SAP/xsk/tree/main/samples/hdb_hdbtable_simple

  • Modules

https://github.com/SAP/xsk/tree/main/modules/parsers/parser-hdbtable

https://github.com/SAP/xsk/tree/main/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/parser/hdbtable

  • Unit Tests

https://github.com/SAP/xsk/blob/5d4a0179e43825a99a623dd1c34a17c42d822813/modules/engines/engine-hdb/src/test/java/com/sap/xsk/hdb/ds/test/XSKTableParserTest.java

  • Integration Tests

https://github.com/SAP/xsk/tree/main/modules/engines/engine-hdb/src/test/java/com/sap/xsk/hdb/ds/test/itest/hdbtable

MySQL database escapes string values differently :

https://github.com/SAP/xsk/blob/3803c76470327a68e0e795997fc1bbdd722abbd8/modules/engines/engine-hdb/src/main/java/com/sap/xsk/utils/XSKHDBUtils.java#L132

PostgreSQL database uses escape symbol to distinguish table name only. Columns, indices, foreign keys, primary keys and unique constraints are not escaped.

https://github.com/SAP/xsk/blob/3803c76470327a68e0e795997fc1bbdd722abbd8/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/processors/table/XSKTableCreateProcessor.java#L55