Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCK-8102: dynamic iceberg table statements #151

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module.exports = {
createDatabase: 'CREATE DATABASE IF NOT EXISTS ${name};\nUSE DATABASE ${name};\n',

createSchema:
'CREATE${transient} SCHEMA IF NOT EXISTS ${name}${managed_access}${data_retention}${comment};\nUSE SCHEMA ${name};\n',
dropSchema: 'DROP SCHEMA IF EXISTS ${name};\n',

createTable:
'CREATE${temporary}${transient} TABLE IF NOT EXISTS\n' +
'CREATE${orReplace}${temporary}${transient} TABLE${tableIfNotExists}\n' +
'\t${name} (\n' +
'\t\t${column_definitions}' +
'${out_of_line_constraints}\n' +
'\t)${tableOptions};\n',

createDynamicTable:
'CREATE${orReplace}${transient} DYNAMIC${iceberg} TABLE${tableIfNotExists}\n' +
'CREATE${orReplace}${transient}${dynamic}${iceberg} TABLE${tableIfNotExists}\n' +
'\t${name}\n' +
'${column_definitions}' +
'${targetLag}' +
Expand All @@ -27,30 +30,44 @@ module.exports = {
'${comment}' +
'${tagsStatement}' +
'${selectStatement};\n',

createLikeTable: 'CREATE TABLE IF NOT EXISTS ${name} LIKE ${source_table}${tableOptions};\n',

createCloneTable: 'CREATE TABLE IF NOT EXISTS ${name} CLONE ${source_table}${tableOptions};\n',

createAsSelect: 'CREATE TABLE IF NOT EXISTS ${name} AS ${selectStatement}${tableOptions};\n',

createExternalTable:
'CREATE EXTERNAL TABLE IF NOT EXISTS \n' +
'\t${name} (\n' +
'\t\t${column_definitions}${out_of_line_constraints}\n' +
'\t)${tableOptions};\n',

columnDefinition:
'${name} ${type}${collation}${default}${identity}${autoincrement}${not_nul}${inline_constraint}${comment}${tag}',

externalColumnDefinition: '${name} ${type} as ${expression}${comment}',

createTableForeignKey: '${constraint}FOREIGN KEY (${columns}) REFERENCES ${primary_table} (${primary_columns})',

alterTableForeignKey:
'ALTER TABLE IF EXISTS ${table_name} ADD ${constraint}FOREIGN KEY (${columns}) REFERENCES ${primary_table} (${primary_columns});',

createView:
'CREATE${secure}${materialized} VIEW IF NOT EXISTS ${name} (\n' +
'\t${column_list}\n' +
')\n${copy_grants}${comment}${tag}${clustering}AS ${select_statement};\n',

createUDF:
'CREATE${orReplace} FUNCTION ${name}(${arguments})\n\tRETURNS ${returnType}${notNull}\n\tLANGUAGE ${language}${parameters}${comment}\n\tAS ${body};\n',

createProcedure:
'CREATE${orReplace} PROCEDURE ${name}(${arguments})\n\tRETURNS ${returnType}${notNull}\n\tLANGUAGE ${language}${parameters}${comment}\n\tAS ${body};\n',

createSequence: 'CREATE SEQUENCE IF NOT EXISTS ${name} START ${start} INCREMENT ${increment}${comment};\n',

createFileFormat: 'CREATE FILE FORMAT IF NOT EXISTS ${name}${options}${comment};\n',

createStage:
'CREATE${temporary} STAGE IF NOT EXISTS ${name} ${url}${storageIntegration}${credentials}${encryption};\n',

Expand All @@ -61,12 +78,16 @@ module.exports = {
alterSchemaScript: 'ALTER SCHEMA IF EXISTS ${name} ',
alterTableScript: 'ALTER${dynamic} TABLE IF EXISTS ${name} ',
alterEntityRename: 'RENAME TO ${name};\n',

alterViewScript: 'ALTER VIEW IF EXISTS ${name} ',
alterMaterializedViewScript: 'ALTER MATERIALIZED VIEW ${name} ',

setPropertySchema: 'SET ${property};\n',
unsetPropertySchema: 'UNSET ${property};\n',
manageAccessSchema: '${access} MANAGED ACCESS;\n',
setPropertyTable: 'SET ${property};\n',
alterViewScript: 'ALTER VIEW IF EXISTS ${name} ',
alterMaterializedViewScript: 'ALTER MATERIALIZED VIEW ${name} ',

manageAccessSchema: '${access} MANAGED ACCESS;\n',

createTag: 'CREATE${orReplace} TAG${ifNotExist} ${name}${allowedValues}${comment};\n',
dropTag: 'DROP TAG IF EXISTS ${name};\n',
alterTag: 'ALTER TAG${ifExists} ${name} ${option}${optionValue};\n',
Expand Down
Loading