|
| 1 | +{{- /*gotype:pbench/cmd/genddl.Schema*/ -}} |
| 2 | +{{ range $key, $value := .SessionVariables -}} |
| 3 | +SET SESSION {{ $key }}='{{ $value }}'; |
| 4 | +{{ end }} |
| 5 | +CREATE SCHEMA IF NOT EXISTS {{ if .Iceberg }}iceberg.{{ .SchemaName }} |
| 6 | +{{- else }}hive.{{ .SchemaName }} |
| 7 | +{{- end }} |
| 8 | +WITH ( |
| 9 | + location = 's3a://presto-workload-v2/{{ .LocationName }}/' |
| 10 | +); |
| 11 | +{{ if .Iceberg }} |
| 12 | +USE iceberg.{{ .SchemaName }}; |
| 13 | +{{- else }} |
| 14 | +USE hive.{{ .SchemaName }}; |
| 15 | +{{- end }} |
| 16 | + |
| 17 | +{{- if .RegisterTables }} |
| 18 | +{{ range .RegisterTables }} |
| 19 | +CALL iceberg.system.register_table('{{ $.SchemaName }}', '{{ .TableName }}', 's3a://presto-workload-v2/{{ .ExternalLocation }}/{{ .TableName }}/metadata'); |
| 20 | +{{- end }} |
| 21 | +{{- end }} |
| 22 | +{{ range .Tables }} |
| 23 | +CREATE TABLE IF NOT EXISTS {{ .Name }} ( |
| 24 | +{{- $first := true }} |
| 25 | +{{- range .Columns }} |
| 26 | + {{- if $first }} |
| 27 | + {{- $first = false }} |
| 28 | + {{- else -}} |
| 29 | + , |
| 30 | + {{- end }} |
| 31 | + {{ .Name }} {{ .Type }} |
| 32 | +{{- end }} |
| 33 | +) |
| 34 | +WITH ( |
| 35 | + format = 'PARQUET', |
| 36 | + {{- if $.Partitioned }} |
| 37 | + {{- if $.Iceberg}} |
| 38 | + partitioning = array['{{ .LastColumn.Name }}'] |
| 39 | + {{- else if .Partitioned }} |
| 40 | + partitioned_by = array['{{ .LastColumn.Name }}'], |
| 41 | + external_location = 's3a://presto-workload-v2/{{ $.PartIcebergName }}/{{ .Name }}/data' |
| 42 | + {{- else }} |
| 43 | + external_location = 's3a://presto-workload-v2/{{ $.IcebergLocationName }}/{{ .Name }}/data/' |
| 44 | + {{- end }} |
| 45 | + {{- else if $.Iceberg }} |
| 46 | + location = 's3a://presto-workload-v2/{{ $.LocationName }}/{{ .Name }}' |
| 47 | + {{- else }} |
| 48 | + external_location = 's3a://presto-workload-v2/{{ $.IcebergLocationName }}/{{ .Name }}/data/' |
| 49 | + {{- end }} |
| 50 | +); |
| 51 | +{{ end }} |
| 52 | +{{- if (and (not .Iceberg) (not .Partitioned)) }} |
| 53 | +{{- range .InsertTables -}} |
| 54 | +ANALYZE {{ .Name }}; |
| 55 | +{{ end -}} |
| 56 | +{{ end }} |
0 commit comments