-
Notifications
You must be signed in to change notification settings - Fork 25
Add Enhanced Ingestion Mode to genddl Tool #92
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
Open
ron-daniel1
wants to merge
12
commits into
prestodb:main
Choose a base branch
from
ron-daniel1:pbench-ingestion
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9fd2ef6
refactor: cmd/genddl for generating ingestion SQL files for generatin…
ron-daniel1 ae4012a
fix: go code formatting fixed
ron-daniel1 9a9d02b
fix: upgrade Go 1.26.2 → 1.26.3 to resolve 4 stdlib vulnerabilities
ron-daniel1 45b4cfa
ci: update GitHub Actions to Go 1.26.3
ron-daniel1 71d7afd
fix: Review comment fixes
ron-daniel1 0ea9281
fix: upgrade Go 1.26.3 → 1.26.4
ron-daniel1 3ea971e
ci: update GitHub Actions to Go 1.26.4
ron-daniel1 35d4d71
ci: staticcheck action updated
ron-daniel1 c61f262
test: Adding textfile with partition testcase for genddl
ron-daniel1 8ebfd42
fix: added newline
ron-daniel1 6a21284
fix: go format fix
ron-daniel1 1086215
fix: Fixed Go template syntax
ron-daniel1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "mode": "enhanced_ingestion", | ||
| "scale_factor": "1", | ||
| "file_format": "parquet", | ||
| "compression_method": "uncompressed", | ||
| "workload": "tpcds", | ||
| "workload_definition": "tpc-ds", | ||
| "iceberg": true, | ||
| "partitioned": false, | ||
| "source_file_format": "CSV", | ||
| "source_catalog": "hive", | ||
| "target_catalog": "iceberg", | ||
| "source_schema": "tpcds_source", | ||
| "target_schema": "tpcds_target", | ||
| "s3_source_location": "s3a://test-bucket/source", | ||
| "s3_target_location": "s3a://test-bucket/target", | ||
| "engine": "presto", | ||
| "session_variables": {} | ||
| } |
19 changes: 19 additions & 0 deletions
19
cmd/genddl/config_enhanced_ingestion_textfile_partitioned.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "mode": "enhanced_ingestion", | ||
| "scale_factor": "100", | ||
| "file_format": "parquet", | ||
| "compression_method": "uncompressed", | ||
| "workload": "tpcds", | ||
| "workload_definition": "tpc-ds", | ||
| "iceberg": true, | ||
| "partitioned": true, | ||
| "source_file_format": "TEXTFILE", | ||
| "source_catalog": "hive", | ||
| "target_catalog": "iceberg", | ||
| "source_schema": "tpcds_source_textfile", | ||
| "target_schema": "tpcds_target_textfile", | ||
| "s3_source_location": "s3a://test-bucket/source-textfile", | ||
| "s3_target_location": "s3a://test-bucket/target-textfile", | ||
| "engine": "presto", | ||
| "session_variables": {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| {{- /*gotype:pbench/cmd/genddl.Schema*/ -}} | ||
| {{- /* This template is used for ENHANCED_INGESTION mode - creates source tables */ -}} | ||
| {{- if .SourceSchema }} | ||
| {{- if .SourceCatalog }} | ||
| CREATE SCHEMA IF NOT EXISTS {{ .SourceCatalog }}.{{ .SourceSchema }} | ||
| WITH ( | ||
| location = '{{ .S3SourceLocation }}/' | ||
| ); | ||
|
|
||
| USE {{ .SourceCatalog }}.{{ .SourceSchema }}; | ||
| {{- else }} | ||
| CREATE SCHEMA IF NOT EXISTS hive.{{ .SourceSchema }} | ||
| WITH ( | ||
| location = '{{ .S3SourceLocation }}/' | ||
| ); | ||
|
|
||
| USE hive.{{ .SourceSchema }}; | ||
| {{- end }} | ||
|
|
||
| {{ range .Tables }} | ||
| CREATE TABLE IF NOT EXISTS {{ .Name }} ( | ||
| {{- $first := true }} | ||
| {{- range .Columns }} | ||
| {{- if $first }} | ||
| {{- $first = false }} | ||
| {{- else }}, | ||
| {{- end }} | ||
| {{- if eq $.SourceFileFormat "CSV" }} | ||
| {{ .Name }} varchar | ||
| {{- else }} | ||
| {{ .Name }} {{ .Type }} | ||
| {{- end }} | ||
| {{- end }}) | ||
| WITH ( | ||
| external_location = '{{ $.S3SourceLocation }}/{{ .Name }}/', | ||
| {{- if eq $.SourceFileFormat "CSV" }} | ||
| format = 'CSV', | ||
| csv_separator = '|' | ||
| {{- else }} | ||
| format = 'TEXTFILE', | ||
| textfile_field_delim = '|' | ||
| {{- end }} | ||
| ); | ||
| {{ end -}} | ||
| {{- end -}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| {{- /*gotype:pbench/cmd/genddl.Schema*/ -}} | ||
| {{- /* This template is used for ENHANCED_INGESTION mode - creates target tables */ -}} | ||
| {{- if .TargetSchema }} | ||
| {{- if .TargetCatalog }} | ||
| CREATE SCHEMA IF NOT EXISTS {{ .TargetCatalog }}.{{ .TargetSchema }} | ||
| WITH ( | ||
| location = '{{ .S3TargetLocation }}/' | ||
| ); | ||
|
|
||
| USE {{ .TargetCatalog }}.{{ .TargetSchema }}; | ||
| {{- else }} | ||
| {{- if .Iceberg }} | ||
| CREATE SCHEMA IF NOT EXISTS iceberg.{{ .TargetSchema }} | ||
| WITH ( | ||
| location = '{{ .S3TargetLocation }}/' | ||
| ); | ||
|
|
||
| USE iceberg.{{ .TargetSchema }}; | ||
| {{- else }} | ||
| CREATE SCHEMA IF NOT EXISTS hive.{{ .TargetSchema }} | ||
| WITH ( | ||
| location = '{{ .S3TargetLocation }}/' | ||
| ); | ||
|
|
||
| USE hive.{{ .TargetSchema }}; | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{ range .Tables }} | ||
| CREATE TABLE IF NOT EXISTS {{ .Name }} ( | ||
| {{- $first := true }} | ||
| {{- range .Columns }} | ||
| {{- if $first }} | ||
| {{- $first = false }} | ||
| {{- else -}} | ||
| , | ||
| {{- end }} | ||
| {{ .Name }} {{ .Type }} | ||
| {{- end }} | ||
| ) | ||
| WITH ( | ||
| format = 'PARQUET' | ||
| {{- if and $.Partitioned .Partitioned }} | ||
| {{- if $.Iceberg}} | ||
| , partitioning = array['{{ .LastColumn.Name }}'] | ||
| {{- else }} | ||
| , partitioned_by = array['{{ .LastColumn.Name }}'] | ||
| {{- end }} | ||
| {{- end }} | ||
| ); | ||
| {{ end -}} | ||
| {{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source_file_formatis unvalidated and case-sensitive. The source template treats anything!= "CSV"as TEXTFILE, while insert generation (insert_table.sql.tmpl:24) treats anything!= "TEXTFILE"as the CSV branch but only emits column expressions when the value is exactly"CSV". A lowercase"csv"therefore creates the source table as TEXTFILE and generates an INSERT with an empty SELECT column list (SELECT\nFROM ...) — invalid SQL, no error. Please validatesource_file_format ∈ {CSV, TEXTFILE}inloadSchemasfor enhanced mode.