World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#11696] improvement(helm): Configurable init-postgresql for external PostgreSQL (#14941)
Danhua Wang795c0fa78ebf
diff --git a/dev/charts/gravitino/templates/NOTES.txt b/dev/charts/gravitino/templates/NOTES.txtindex c72f34d14d..cc495554a4 100644--- a/dev/charts/gravitino/templates/NOTES.txt+++ b/dev/charts/gravitino/templates/NOTES.txt@@ -69,6 +69,23 @@ Override postgresql.auth.password (or set postgresql.auth.existingSecret)before any non-trial deployment.{{- end }}+{{- if and (eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true") .Values.postgresql.init.enabled }}++NOTE: External PostgreSQL schema init is enabled (postgresql.init.enabled).+The init-postgresql container requires postgresql.init.existingSecret+(operator-managed Secret with the application user password). Host, port,+sslmode, and currentSchema default from entity.jdbcUrl when the matching+postgresql.init.* fields are empty. JDBC URL host/port parsing supports only a+single host:port; IPv6 bracket literals or multi-host authorities fail at+render — set postgresql.init.host/port for those forms. Database name is taken+from entity.jdbcUrl. currentSchema is applied via PGOPTIONS search_path so+schema SQL matches Gravitino's JDBC schema. Readiness waits up to+postgresql.init.waitTimeoutSeconds (default 300) then fails with the psql+error. sslmode=require needs no CA; verify-ca / verify-full require+postgresql.init.ssl.existingSecret (mounted as PGSSLROOTCERT; JDBC sslrootcert+is not inherited).+{{- end }}+To check pod status:kubectl get pods --namespace {{ include "gravitino.namespace" . }}diff --git a/dev/charts/gravitino/templates/_helpers.tpl b/dev/charts/gravitino/templates/_helpers.tplindex 54ca630c48..e11c23de5a 100644--- a/dev/charts/gravitino/templates/_helpers.tpl+++ b/dev/charts/gravitino/templates/_helpers.tpl@@ -108,7 +108,268 @@ Return the proper MySQL image name for the init-mysql initContainerReturn the proper Postgresql image name for the init-postgresql initContainer*/}}{{- define "init-postgresql.image" -}}+{{- include "gravitino.imageReference" (dict "imageRoot" .Values.postgresql.image "global" .Values.global) -}}+{{- end -}}++{{/*+True when the entity store uses an external PostgreSQL JDBC URL (not in-chart Bitnami).+*/}}+{{- define "gravitino.entityUsesExternalPostgresql" -}}+{{- $url := .Values.entity.jdbcUrl | default "" -}}+{{- if and (not .Values.mysql.enabled) (not .Values.postgresql.enabled) (hasPrefix "jdbc:postgresql:" $url) -}}+true+{{- end -}}+{{- end -}}++{{/*+True when the init-postgresql schema init container should be rendered.+In-chart Bitnami PostgreSQL always runs schema init. External PostgreSQL runs+only when postgresql.init.enabled is true (opt-in; see issue #9013 for hook Job).+*/}}+{{- define "gravitino.postgresqlSchemaInitEnabled" -}}{{- if .Values.postgresql.enabled -}}- {{- include "gravitino.imageReference" (dict "imageRoot" .Values.postgresql.image "global" .Values.global) -}}+true+{{- else if and (eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true") .Values.postgresql.init.enabled -}}+true+{{- end -}}+{{- end -}}++{{/*+Authority segment (host[:port]) from entity.jdbcUrl for PostgreSQL.++Only a single host:port is supported. The helpers split authority on the first+colon and do not parse IPv6 bracket literals (e.g. [::1]:5432) or multi-host+JDBC authorities (host1:5432,host2:5432). When the authority contains "[" or+"," and host/port would be derived from the URL, rendering fails and asks for+postgresql.init.host and postgresql.init.port.+*/}}+{{- define "gravitino.entityJdbcAuthorityFromUrl" -}}+{{- $url := .Values.entity.jdbcUrl | default "" -}}+{{- if hasPrefix "jdbc:postgresql://" $url -}}+{{- $path := trimPrefix "jdbc:postgresql://" $url -}}+{{- $auth := (splitList "/" $path | first) -}}+{{- if or (contains "[" $auth) (contains "," $auth) -}}+{{- fail "entity.jdbcUrl authority is IPv6 or multi-host; set postgresql.init.host and postgresql.init.port explicitly (JDBC URL host/port fallback supports only a single host:port)" -}}+{{- end -}}+{{- $auth -}}+{{- end -}}+{{- end -}}++{{/*+Hostname from entity.jdbcUrl authority (external PostgreSQL).++Supports a single hostname or IPv4 host only (see entityJdbcAuthorityFromUrl).+*/}}+{{- define "gravitino.entityJdbcHostFromUrl" -}}+{{- $auth := include "gravitino.entityJdbcAuthorityFromUrl" . | trim -}}+{{- if $auth -}}+{{- if contains ":" $auth -}}+{{- $parts := splitList ":" $auth -}}+{{- index $parts 0 -}}+{{- else -}}+{{- $auth -}}+{{- end -}}+{{- end -}}+{{- end -}}++{{/*+Port from entity.jdbcUrl authority (defaults to 5432 when omitted).++Supports a single host:port only (see entityJdbcAuthorityFromUrl).+*/}}+{{- define "gravitino.entityJdbcPortFromUrl" -}}+{{- $auth := include "gravitino.entityJdbcAuthorityFromUrl" . | trim -}}+{{- if and $auth (contains ":" $auth) -}}+{{- $parts := splitList ":" $auth -}}+{{- index $parts 1 -}}+{{- else -}}+5432+{{- end -}}+{{- end -}}++{{/*+sslmode query parameter from entity.jdbcUrl.++When sslmode is absent, JDBC ssl=true (or ssl=1) implies certificate and hostname+verification, aligned with the PostgreSQL JDBC driver — mapped to verify-full for psql.+*/}}+{{- define "gravitino.entityJdbcSslModeFromUrl" -}}+{{- $url := .Values.entity.jdbcUrl | default "" -}}+{{- $match := regexFind "sslmode=([^&]+)" $url -}}+{{- if $match -}}+{{- trimPrefix "sslmode=" $match -}}+{{- else if or (regexFind "[?&]ssl=true(&|$)" $url) (regexFind "[?&]ssl=1(&|$)" $url) -}}+verify-full+{{- end -}}+{{- end -}}++{{/*+currentSchema query parameter from entity.jdbcUrl.+*/}}+{{- define "gravitino.entityJdbcCurrentSchemaFromUrl" -}}+{{- $url := .Values.entity.jdbcUrl | default "" -}}+{{- $match := regexFind "currentSchema=([^&]+)" $url -}}+{{- if $match -}}+{{- trimPrefix "currentSchema=" $match -}}+{{- end -}}+{{- end -}}++{{/*+Hostname for init-postgresql psql (-h).+*/}}+{{- define "gravitino.postgresqlInitHost" -}}+{{- if .Values.postgresql.init.host -}}+{{- .Values.postgresql.init.host -}}+{{- else if .Values.postgresql.enabled -}}+{{- printf "%s-postgresql" .Release.Name -}}+{{- else -}}+{{- $fromUrl := include "gravitino.entityJdbcHostFromUrl" . | trim -}}+{{- if $fromUrl -}}+{{- $fromUrl -}}+{{- else -}}+{{- fail "postgresql.init.host is required (or set a parseable entity.jdbcUrl host) when postgresql.init.enabled is true for external PostgreSQL" -}}+{{- end -}}+{{- end -}}+{{- end -}}++{{/*+Port for init-postgresql (PGPORT).+*/}}+{{- define "gravitino.postgresqlInitPort" -}}+{{- if .Values.postgresql.init.port -}}+{{- .Values.postgresql.init.port | toString -}}+{{- else if .Values.postgresql.enabled -}}+5432+{{- else -}}+{{- include "gravitino.entityJdbcPortFromUrl" . | trim -}}+{{- end -}}+{{- end -}}++{{/*+sslmode for init-postgresql (PGSSLMODE).+*/}}+{{- define "gravitino.postgresqlInitSslMode" -}}+{{- if .Values.postgresql.init.sslMode -}}+{{- .Values.postgresql.init.sslMode -}}+{{- else if eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true" -}}+{{- include "gravitino.entityJdbcSslModeFromUrl" . | trim -}}+{{- end -}}+{{- end -}}++{{/*+PostgreSQL search_path / currentSchema for init-postgresql (PGOPTIONS).++Prefer postgresql.init.currentSchema; otherwise currentSchema from entity.jdbcUrl.+Empty means libpq default (typically public).++Only simple (unquoted-style) identifiers are accepted. Fold to lowercase so+lookup (pg_namespace.nspname), CREATE SCHEMA, and PGOPTIONS search_path all use+the same name — matching PostgreSQL unquoted-identifier / JDBC currentSchema+folding (e.g. currentSchema=App → app).+*/}}+{{- define "gravitino.postgresqlInitCurrentSchema" -}}+{{- $schema := "" -}}+{{- if .Values.postgresql.init.currentSchema -}}+{{- $schema = .Values.postgresql.init.currentSchema | toString | trim -}}+{{- else if eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true" -}}+{{- $schema = include "gravitino.entityJdbcCurrentSchemaFromUrl" . | trim -}}+{{- end -}}+{{- if $schema -}}+{{- if not (regexMatch "^[A-Za-z_][A-Za-z0-9_]*$" $schema) -}}+{{- fail (printf "postgresql.init.currentSchema / entity.jdbcUrl currentSchema %q must be a simple PostgreSQL identifier (letters, digits, underscore); set postgresql.init.currentSchema explicitly if needed" $schema) -}}+{{- end -}}+{{- $schema | lower -}}+{{- end -}}+{{- end -}}++{{/*+CA Secret name for init-postgresql when sslmode needs a root cert.+*/}}+{{- define "gravitino.postgresqlInitSslCaSecretName" -}}+{{- $ssl := .Values.postgresql.init.ssl | default dict -}}+{{- $secret := $ssl.existingSecret | default "" | toString | trim -}}+{{- if $secret -}}+{{- $secret -}}+{{- end -}}+{{- end -}}++{{/*+CA Secret key for the root certificate mounted into init-postgresql.+*/}}+{{- define "gravitino.postgresqlInitSslCaKey" -}}+{{- $ssl := .Values.postgresql.init.ssl | default dict -}}+{{- $ssl.caCert | default "ca.crt" | toString | trim -}}+{{- end -}}++{{/*+Fail when verify-ca / verify-full is set without a CA Secret for init-postgresql.+JDBC sslrootcert is not carried into the init container; operators must mount a CA+via postgresql.init.ssl.existingSecret (PGSSLROOTCERT). sslmode=require needs no CA.+*/}}+{{- define "gravitino.postgresqlInitSslValidate" -}}+{{- $mode := include "gravitino.postgresqlInitSslMode" . | trim | lower -}}+{{- $caSecret := include "gravitino.postgresqlInitSslCaSecretName" . | trim -}}+{{- if and (or (eq $mode "verify-ca") (eq $mode "verify-full")) (not $caSecret) -}}+{{- fail "postgresql.init.ssl.existingSecret (and caCert) is required when sslmode is verify-ca or verify-full; the init container does not inherit JDBC sslrootcert. Use sslmode=require without a CA, or mount a CA Secret and set PGSSLROOTCERT via init.ssl" -}}+{{- end -}}+{{- end -}}++{{/*+Secret name for init-postgresql POSTGRES_PASSWORD secretKeyRef.+*/}}+{{- define "gravitino.postgresqlInitSecretName" -}}+{{- if .Values.postgresql.init.existingSecret -}}+{{- .Values.postgresql.init.existingSecret -}}+{{- else if and .Values.postgresql.enabled .Values.postgresql.auth.existingSecret -}}+{{- tpl (.Values.postgresql.auth.existingSecret | toString) . -}}+{{- else if .Values.postgresql.enabled -}}+{{- printf "%s-postgresql" .Release.Name -}}+{{- else if eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true" -}}+{{- fail "postgresql.init.existingSecret is required when postgresql.init.enabled is true for external PostgreSQL" -}}+{{- end -}}+{{- end -}}++{{/*+Database name segment from entity.jdbcUrl (postgresql JDBC URLs only).+*/}}+{{- define "gravitino.entityJdbcDatabaseFromUrl" -}}+{{- $url := .Values.entity.jdbcUrl | default "" -}}+{{- if hasPrefix "jdbc:postgresql://" $url -}}+{{- $path := trimPrefix "jdbc:postgresql://" $url -}}+{{- $parts := splitList "/" $path -}}+{{- if ge (len $parts) 2 -}}+{{- $dbPart := index $parts 1 -}}+{{- $db := splitList "?" $dbPart | first -}}+{{- if $db -}}+{{- $db -}}+{{- end -}}+{{- end -}}+{{- end -}}+{{- end -}}++{{/*+Application user for init-postgresql POSTGRES_USER.+*/}}+{{- define "gravitino.postgresqlInitUsername" -}}+{{- if .Values.postgresql.enabled -}}+{{- .Values.postgresql.auth.username -}}+{{- else -}}+{{- .Values.entity.jdbcUser -}}+{{- end -}}+{{- end -}}++{{/*+Database name for init-postgresql GRAVITINO_DB.+*/}}+{{- define "gravitino.postgresqlInitDatabase" -}}+{{- if eq (include "gravitino.entityUsesExternalPostgresql" . | trim) "true" -}}+{{- $fromUrl := include "gravitino.entityJdbcDatabaseFromUrl" . | trim -}}+{{- if $fromUrl -}}+{{- $fromUrl -}}+{{- else -}}+{{- fail "could not parse database name from entity.jdbcUrl for init-postgresql; use jdbc:postgresql://<host>:<port>/<database>" -}}+{{- end -}}+{{- else -}}+{{- .Values.postgresql.auth.database | default "gravitino" -}}{{- end -}}{{- end -}}\ No newline at end of filediff --git a/dev/charts/gravitino/templates/deployment.yaml b/dev/charts/gravitino/templates/deployment.yamlindex e1f30e3651..74723b0574 100644--- a/dev/charts/gravitino/templates/deployment.yaml+++ b/dev/charts/gravitino/templates/deployment.yaml@@ -125,7 +125,17 @@ spec:- mountPath: /scriptsname: scripts-emptydir{{- end }}- {{- if .Values.postgresql.enabled }}+ {{- if eq (include "gravitino.postgresqlSchemaInitEnabled" . | trim) "true" }}+ {{- $_ := include "gravitino.postgresqlInitSslValidate" . }}+ {{- $pgInitHost := include "gravitino.postgresqlInitHost" . | trim }}+ {{- $pgInitSecret := include "gravitino.postgresqlInitSecretName" . | trim }}+ {{- $pgInitSecretKey := .Values.postgresql.init.existingSecretPasswordKey | default "password" }}+ {{- $pgInitPort := include "gravitino.postgresqlInitPort" . | trim }}+ {{- $pgInitSslMode := include "gravitino.postgresqlInitSslMode" . | trim }}+ {{- $pgInitCurrentSchema := include "gravitino.postgresqlInitCurrentSchema" . | trim }}+ {{- $pgInitSslCaSecret := include "gravitino.postgresqlInitSslCaSecretName" . | trim }}+ {{- $pgInitWaitTimeout := .Values.postgresql.init.waitTimeoutSeconds | default 300 }}+ {{- $pgInitConnectTimeout := .Values.postgresql.init.connectTimeoutSeconds | default 5 }}- name: init-postgresqlimage: {{ include "init-postgresql.image" . }}imagePullPolicy: "{{ .Values.image.pullPolicy }}"@@ -133,10 +143,46 @@ spec:- /bin/bash- -c- |- while ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name }}-postgresql -U $POSTGRES_USER -c "SELECT 1"; do+ set -e+ timeout={{ $pgInitWaitTimeout }}+ case "$timeout" in+ ''|*[!0-9]*) echo "ERROR: waitTimeoutSeconds must be a positive integer" >&2; exit 1 ;;+ esac+ if [ "$timeout" -lt 1 ]; then+ echo "ERROR: waitTimeoutSeconds must be a positive integer" >&2+ exit 1+ fi+ deadline=$((SECONDS + timeout))+ last_err=""+ while true; do+ remaining=$((deadline - SECONDS))+ if [ "$remaining" -lt 1 ]; then+ echo "ERROR: timed out after ${timeout}s waiting for PostgreSQL at {{ $pgInitHost }}:$PGPORT/$GRAVITINO_DB" >&2+ echo "$last_err" >&2+ exit 1+ fi+ set +e+ err=$(PGPASSWORD="$POSTGRES_PASSWORD" timeout "$remaining" psql -h {{ $pgInitHost }} -U $POSTGRES_USER -d $GRAVITINO_DB -c "SELECT 1" 2>&1)+ rc=$?+ set -e+ if [ "$rc" -eq 0 ]; then+ break+ fi+ last_err="$err"+ if [ "$rc" -eq 124 ]; then+ echo "ERROR: timed out after ${timeout}s waiting for PostgreSQL at {{ $pgInitHost }}:$PGPORT/$GRAVITINO_DB" >&2+ echo "$err" >&2+ exit 1+ fiecho "Waiting for PostgreSQL to be ready..."sleep 2done+ if [ -n "${PG_CURRENT_SCHEMA:-}" ]; then+ schema_exists=$(PGPASSWORD="$POSTGRES_PASSWORD" psql -h {{ $pgInitHost }} -U $POSTGRES_USER -d $GRAVITINO_DB -v ON_ERROR_STOP=1 -tAc "SELECT 1 FROM pg_namespace WHERE nspname = '${PG_CURRENT_SCHEMA}'")+ if [ "$schema_exists" != "1" ]; then+ PGPASSWORD="$POSTGRES_PASSWORD" psql -h {{ $pgInitHost }} -U $POSTGRES_USER -d $GRAVITINO_DB -v ON_ERROR_STOP=1 -c "CREATE SCHEMA \"${PG_CURRENT_SCHEMA}\""+ fi+ fiVERSION=$(cat /scripts/version.txt)if [ -z "$VERSION" ]; thenecho "ERROR:Please set VERSION"@@ -155,29 +201,52 @@ spec:fiecho "Schema file: $schema_file"echo "Upgrade file: $upgrade_file"- if ! PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name }}-postgresql -U $POSTGRES_USER -d $GRAVITINO_DB -f "$upgrade_file"; then+ if ! PGPASSWORD="$POSTGRES_PASSWORD" psql -h {{ $pgInitHost }} -U $POSTGRES_USER -d $GRAVITINO_DB -f "$upgrade_file"; thenecho "WARNING: Upgrade script failed: $upgrade_file" >&2echo "Continuing with schema script..." >&2fi- PGPASSWORD=$POSTGRES_PASSWORD psql -h {{ .Release.Name }}-postgresql -U $POSTGRES_USER -d $GRAVITINO_DB -f "$schema_file"+ PGPASSWORD="$POSTGRES_PASSWORD" psql -h {{ $pgInitHost }} -U $POSTGRES_USER -d $GRAVITINO_DB -v ON_ERROR_STOP=1 -f "$schema_file"resources:{{- toYaml .Values.initResources | nindent 12 }}securityContext:{{- toYaml .Values.initContainerSecurityContext | nindent 12 }}env:- name: POSTGRES_USER- value: {{ .Values.postgresql.auth.username }}+ value: {{ include "gravitino.postgresqlInitUsername" . | quote }}- name: GRAVITINO_DB- value: {{ .Values.postgresql.auth.database }}+ value: {{ include "gravitino.postgresqlInitDatabase" . | quote }}+ - name: PGPORT+ value: {{ $pgInitPort | quote }}+ - name: PGCONNECT_TIMEOUT+ value: {{ $pgInitConnectTimeout | quote }}+ {{- if $pgInitSslMode }}+ - name: PGSSLMODE+ value: {{ $pgInitSslMode | quote }}+ {{- end }}+ {{- if $pgInitCurrentSchema }}+ - name: PG_CURRENT_SCHEMA+ value: {{ $pgInitCurrentSchema | quote }}+ - name: PGOPTIONS+ value: {{ printf "-c search_path=%s" $pgInitCurrentSchema | quote }}+ {{- end }}+ {{- if $pgInitSslCaSecret }}+ - name: PGSSLROOTCERT+ value: /db-ssl/ca.crt+ {{- end }}- name: POSTGRES_PASSWORDvalueFrom:secretKeyRef:- name: {{ .Release.Name }}-postgresql- key: password+ name: {{ $pgInitSecret }}+ key: {{ $pgInitSecretKey }}volumeMounts:- mountPath: /scriptsname: scripts-emptydir- {{- end }}+ {{- if $pgInitSslCaSecret }}+ - name: postgresql-init-ssl+ mountPath: /db-ssl+ readOnly: true+ {{- end }}+ {{- end }}containers:- name: {{ include "gravitino.name" . }}image: {{ include "gravitino.image" . }}@@ -241,7 +310,15 @@ spec:configMap:name: {{ include "gravitino.fullname" . }}- emptyDir: {}- name: scripts-emptydir+ name: scripts-emptydir+ {{- if and (eq (include "gravitino.postgresqlSchemaInitEnabled" . | trim) "true") (include "gravitino.postgresqlInitSslCaSecretName" . | trim) }}+ - name: postgresql-init-ssl+ secret:+ secretName: {{ include "gravitino.postgresqlInitSslCaSecretName" . | trim }}+ items:+ - key: {{ include "gravitino.postgresqlInitSslCaKey" . | trim }}+ path: ca.crt+ {{- end }}{{- if not .Values.persistence.enabled }}- name: storageemptyDir: {}diff --git a/dev/charts/gravitino/tests/deployment_test.yaml b/dev/charts/gravitino/tests/deployment_test.yamlindex b0e63334e2..31767a569b 100644--- a/dev/charts/gravitino/tests/deployment_test.yaml+++ b/dev/charts/gravitino/tests/deployment_test.yaml@@ -265,6 +265,703 @@ tests:name: GRAVITINO_DBvalue: gravitinoany: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_PASSWORD+ valueFrom:+ secretKeyRef:+ name: gravitino-postgresql+ key: password+ any: true+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "psql -h gravitino-postgresql -U \\$POSTGRES_USER -d \\$GRAVITINO_DB -c"+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGPORT+ value: "5432"+ any: true++ - it: does not render init-postgresql when init.enabled but entity.jdbcUrl is not PostgreSQL+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:mysql://mysql.example.ci.local:3306/gravitino+ jdbcDriver: com.mysql.cj.jdbc.Driver+ jdbcUser: gravitino+ asserts:+ - notContains:+ path: spec.template.spec.initContainers+ content:+ name: init-postgresql+ any: true++ - it: does not render init-postgresql for external PostgreSQL unless init.enabled+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ entity:+ jdbcUrl: jdbc:postgresql://gravitino-cnpg-rw:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - notContains:+ path: spec.template.spec.initContainers+ content:+ name: init-postgresql+ any: true++ - it: uses postgresql.auth.existingSecret for init when Bitnami chart is enabled+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: true+ auth:+ existingSecret: gravitino-pg-credentials+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_PASSWORD+ valueFrom:+ secretKeyRef:+ name: gravitino-pg-credentials+ key: password+ any: true++ - it: derives GRAVITINO_DB from entity.jdbcUrl for external PostgreSQL+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ host: pg.example.ci.local+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino_meta?sslmode=require+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: GRAVITINO_DB+ value: gravitino_meta+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLMODE+ value: require+ any: true++ - it: derives host port and sslmode from entity.jdbcUrl for external PostgreSQL+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5433/gravitino_meta?sslmode=require+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "psql -h pg.example.ci.local -U \\$POSTGRES_USER -d \\$GRAVITINO_DB -c"+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGPORT+ value: "5433"+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLMODE+ value: require+ any: true++ - it: fails when external PostgreSQL entity.jdbcUrl has no database path+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ host: pg.example.ci.local+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/+ asserts:+ - failedTemplate:+ errorMessage: "could not parse database name from entity.jdbcUrl for init-postgresql; use jdbc:postgresql://<host>:<port>/<database>"++ - it: renders custom PostgreSQL init secret and host when postgresql.init is set+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: true+ init:+ host: gravitino-cnpg-rw+ existingSecret: gravitino-cnpg-secret+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_PASSWORD+ valueFrom:+ secretKeyRef:+ name: gravitino-cnpg-secret+ key: password+ any: true+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "psql -h gravitino-cnpg-rw"++ - it: renders init-postgresql for external PostgreSQL entity store+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ host: gravitino-cnpg-rw.gravitino.svc+ existingSecret: gravitino-cnpg-secret+ entity:+ jdbcUrl: jdbc:postgresql://gravitino-cnpg-rw.gravitino.svc:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ jdbcPassword: ignored-in-configmap+ asserts:+ - contains:+ path: spec.template.spec.initContainers+ content:+ name: init-postgresql+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_USER+ value: gravitino_app+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_PASSWORD+ valueFrom:+ secretKeyRef:+ name: gravitino-cnpg-secret+ key: password+ any: true+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "psql -h gravitino-cnpg-rw.gravitino.svc"++ - it: fails when external PostgreSQL init enabled without postgresql.init.existingSecret+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ host: gravitino-cnpg-rw+ entity:+ jdbcUrl: jdbc:postgresql://gravitino-cnpg-rw:5432/gravitino+ asserts:+ - failedTemplate:+ errorMessage: "postgresql.init.existingSecret is required when postgresql.init.enabled is true for external PostgreSQL"++ - it: fails when entity.jdbcUrl authority is IPv6 and host/port are derived from the URL+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://[::1]:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorMessage: "entity.jdbcUrl authority is IPv6 or multi-host; set postgresql.init.host and postgresql.init.port explicitly (JDBC URL host/port fallback supports only a single host:port)"++ - it: fails when entity.jdbcUrl authority is multi-host and host/port are derived from the URL+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg1.example.ci.local:5432,pg2.example.ci.local:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorMessage: "entity.jdbcUrl authority is IPv6 or multi-host; set postgresql.init.host and postgresql.init.port explicitly (JDBC URL host/port fallback supports only a single host:port)"++ - it: renders when IPv6 entity.jdbcUrl has explicit postgresql.init.host and port+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ host: "::1"+ port: 5432+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://[::1]:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "psql -h ::1"+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGPORT+ value: "5432"+ any: true++ - it: overrides JDBC-derived port and sslmode with postgresql.init.port and sslMode+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ port: 15432+ sslMode: verify-full+ ssl:+ existingSecret: gravitino-pg-ca+ caCert: ca.crt+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5433/gravitino?sslmode=require+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGPORT+ value: "15432"+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLMODE+ value: verify-full+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLROOTCERT+ value: /db-ssl/ca.crt+ any: true+ - contains:+ path: spec.template.spec.volumes+ content:+ name: postgresql-init-ssl+ any: true+++ - it: derives currentSchema from entity.jdbcUrl into PGOPTIONS search_path+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino_meta?currentSchema=gravitino&sslmode=require+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PG_CURRENT_SCHEMA+ value: gravitino+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGOPTIONS+ value: "-c search_path=gravitino"+ any: true+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "pg_namespace WHERE nspname"+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: 'CREATE SCHEMA.*PG_CURRENT_SCHEMA'++ - it: overrides JDBC currentSchema with postgresql.init.currentSchema+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ currentSchema: custom_schema+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino_meta?currentSchema=gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGOPTIONS+ value: "-c search_path=custom_schema"+ any: true++ - it: folds mixed-case currentSchema to lowercase for lookup create and search_path+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ currentSchema: App+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino_meta?currentSchema=OtherSchema+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PG_CURRENT_SCHEMA+ value: app+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGOPTIONS+ value: "-c search_path=app"+ any: true+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "pg_namespace WHERE nspname"+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: 'CREATE SCHEMA.*PG_CURRENT_SCHEMA'++ - it: folds mixed-case currentSchema from entity.jdbcUrl to lowercase+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino_meta?currentSchema=App&sslmode=require+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PG_CURRENT_SCHEMA+ value: app+ any: true+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGOPTIONS+ value: "-c search_path=app"+ any: true++ - it: fails when sslmode is verify-full without postgresql.init.ssl.existingSecret+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ sslMode: verify-full+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorPattern: "postgresql.init.ssl.existingSecret .* verify-ca or verify-full"++ - it: fails when entity.jdbcUrl sslmode is verify-ca without CA Secret+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino?sslmode=verify-ca+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorPattern: "postgresql.init.ssl.existingSecret .* verify-ca or verify-full"+++ - it: fails when currentSchema is not a simple identifier+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ currentSchema: 'bad;schema'+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorPattern: "must be a simple PostgreSQL identifier"++ - it: renders wait timeout in init-postgresql readiness loop+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ waitTimeoutSeconds: 120+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "timeout=120"+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: "timed out after"+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: 'timeout "\$remaining"'+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: 'PGPASSWORD="\$POSTGRES_PASSWORD" timeout'++ - it: renders PGCONNECT_TIMEOUT for init-postgresql+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ connectTimeoutSeconds: 10+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGCONNECT_TIMEOUT+ value: "10"+ any: true++ - it: applies ON_ERROR_STOP to baseline schema psql+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: true+ asserts:+ - matchRegex:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].command[2]+ pattern: 'ON_ERROR_STOP=1 -f "\$schema_file"'++ - it: does not inherit entity.jdbcUrl sslmode or currentSchema when Bitnami PostgreSQL is enabled+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: true+ entity:+ jdbcUrl: jdbc:postgresql://ignored.example.ci.local:5432/gravitino?sslmode=verify-full¤tSchema=ignored_schema+ asserts:+ - notContains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLMODE+ value: verify-full+ any: true+ - notContains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGOPTIONS+ value: "-c search_path=ignored_schema"+ any: true+ - notContains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PG_CURRENT_SCHEMA+ value: ignored_schema+ any: true++ - it: renders numeric database name from jdbcUrl as quoted string env+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local/12345+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: GRAVITINO_DB+ value: "12345"+ any: true++ - it: maps JDBC ssl=true to verify-full and requires CA Secret+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino?ssl=true+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - failedTemplate:+ errorPattern: "postgresql.init.ssl.existingSecret .* verify-ca or verify-full"++ - it: maps JDBC ssl=true to verify-full when CA Secret is set+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: false+ init:+ enabled: true+ existingSecret: gravitino-pg-secret+ ssl:+ existingSecret: gravitino-pg-ca+ entity:+ jdbcUrl: jdbc:postgresql://pg.example.ci.local:5432/gravitino?ssl=true+ jdbcDriver: org.postgresql.Driver+ jdbcUser: gravitino_app+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: PGSSLMODE+ value: verify-full+ any: true++ - it: evaluates postgresql.auth.existingSecret as a template for Bitnami init+ template: deployment.yaml+ release:+ name: gravitino+ set:+ postgresql:+ enabled: true+ auth:+ existingSecret: "{{ .Release.Name }}-pg-credentials"+ asserts:+ - contains:+ path: spec.template.spec.initContainers[?(@.name == "init-postgresql")].env+ content:+ name: POSTGRES_PASSWORD+ valueFrom:+ secretKeyRef:+ name: gravitino-pg-credentials+ key: password+ any: true- it: renders topologySpreadConstraints when settemplate: deployment.yamldiff --git a/dev/charts/gravitino/values.yaml b/dev/charts/gravitino/values.yamlindex 4d2dada9f7..ab802193fc 100644--- a/dev/charts/gravitino/values.yaml+++ b/dev/charts/gravitino/values.yaml@@ -114,6 +114,67 @@ postgresql:## The value is evaluated as a template.##existingSecret: ""+ init:+ ## @param init.enabled Run init-postgresql for an external PostgreSQL entity store.+ ## Ignored when postgresql.enabled is true (in-chart Bitnami always runs schema init).+ ## Default false preserves prior behavior for external PostgreSQL (manual schema or #9013 Job).+ ##+ enabled: false+ ## @param init.host PostgreSQL hostname for the init-postgresql psql client (-h).+ ## When postgresql.enabled is true and this is empty, defaults to {{ .Release.Name }}-postgresql.+ ## For external PostgreSQL with init.enabled=true, falls back to the host in entity.jdbcUrl when empty.+ ## JDBC URL fallback supports only a single host or host:port (IPv4 / DNS name).+ ## IPv6 bracket URLs and multi-host JDBC authorities fail at render; set host (and port) here instead.+ ##+ host: ""+ ## @param init.port TCP port for psql (PGPORT). Defaults to 5432, or the port in entity.jdbcUrl for external PostgreSQL.+ ## Same single host:port limitation as init.host when deriving from entity.jdbcUrl.+ ##+ port: ""+ ## @param init.sslMode libpq sslmode (PGSSLMODE), for example require. For external PostgreSQL, defaults to+ ## sslmode from entity.jdbcUrl when set, or verify-full when the URL has ssl=true/ssl=1 and no sslmode (JDBC TLS default).+ ## In-chart Bitnami (postgresql.enabled=true) does not inherit entity.jdbcUrl sslmode.+ ## sslmode=require does not need a CA. verify-ca and verify-full require init.ssl.existingSecret+ ## (JDBC sslrootcert is not copied into the init container).+ ##+ sslMode: ""+ ## @param init.currentSchema PostgreSQL schema for search_path (PGOPTIONS). For external PostgreSQL, defaults to+ ## currentSchema from entity.jdbcUrl. In-chart Bitnami does not inherit entity.jdbcUrl currentSchema.+ ## Aligns psql CREATE TABLE with Gravitino's JDBC currentSchema (docs: jdbc:postgresql://host:5432/db?currentSchema=schema).+ ## Simple identifiers only; mixed case is folded to lowercase for lookup, CREATE SCHEMA, and search_path+ ## (unquoted PostgreSQL identifier / JDBC currentSchema semantics, e.g. App → app).+ ## When set, the init container creates the schema only if it is missing (pg_namespace check),+ ## so application roles without database-level CREATE can still run when an admin pre-created the schema.+ ##+ currentSchema: ""+ ## @param init.waitTimeoutSeconds Max seconds to wait for PostgreSQL readiness before failing the init container.+ ## On timeout the last psql error is printed. Avoids hanging forever on wrong password, missing DB, or TLS failures.+ ## Each readiness probe is bounded by the remaining wait time (GNU timeout) so a stalled psql cannot overshoot the deadline.+ ##+ waitTimeoutSeconds: 300+ ## @param init.connectTimeoutSeconds libpq connect timeout in seconds (PGCONNECT_TIMEOUT) for every psql call.+ ##+ connectTimeoutSeconds: 5+ ## TLS CA for init-postgresql when sslmode is verify-ca or verify-full.+ ## Mounted at /db-ssl/ca.crt and exported as PGSSLROOTCERT.+ ##+ ssl:+ ## @param init.ssl.existingSecret Secret holding the PostgreSQL server CA (and optional client material unused by psql here).+ ## Required when sslmode is verify-ca or verify-full.+ ##+ existingSecret: ""+ ## @param init.ssl.caCert Key within existingSecret for the CA certificate file.+ ##+ caCert: ca.crt+ ## @param init.existingSecret Kubernetes Secret name for the init container POSTGRES_PASSWORD.+ ## When postgresql.enabled is true and this is empty, defaults to postgresql.auth.existingSecret+ ## if set, otherwise {{ .Release.Name }}-postgresql.+ ## Set this when the password Secret does not follow the Bitnami release name convention.+ ##+ existingSecret: ""+ ## @param init.existingSecretPasswordKey Key in init.existingSecret for the application user password.+ ##+ existingSecretPasswordKey: password## THE CONFIGURATION FOR Gravitino ENTITY STORE##diff --git a/scripts/postgresql/schema-0.7.0-postgresql.sql b/scripts/postgresql/schema-0.7.0-postgresql.sqlindex da13cfd911..7d02afbe10 100644--- a/scripts/postgresql/schema-0.7.0-postgresql.sql+++ b/scripts/postgresql/schema-0.7.0-postgresql.sql@@ -161,9 +161,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-0.8.0-postgresql.sql b/scripts/postgresql/schema-0.8.0-postgresql.sqlindex d964c1f80e..0eee956dbd 100644--- a/scripts/postgresql/schema-0.8.0-postgresql.sql+++ b/scripts/postgresql/schema-0.8.0-postgresql.sql@@ -161,9 +161,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-0.9.0-postgresql.sql b/scripts/postgresql/schema-0.9.0-postgresql.sqlindex b8e739bf62..40d8fbf36d 100644--- a/scripts/postgresql/schema-0.9.0-postgresql.sql+++ b/scripts/postgresql/schema-0.9.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-1.0.0-postgresql.sql b/scripts/postgresql/schema-1.0.0-postgresql.sqlindex e571156318..99f67c2938 100644--- a/scripts/postgresql/schema-1.0.0-postgresql.sql+++ b/scripts/postgresql/schema-1.0.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX table_column_version_info_idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX table_column_version_info_idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX table_column_version_info_idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-1.1.0-postgresql.sql b/scripts/postgresql/schema-1.1.0-postgresql.sqlindex 2f3bf16fab..8a61fdeeea 100644--- a/scripts/postgresql/schema-1.1.0-postgresql.sql+++ b/scripts/postgresql/schema-1.1.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX table_column_version_info_idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX table_column_version_info_idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX table_column_version_info_idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-1.2.0-postgresql.sql b/scripts/postgresql/schema-1.2.0-postgresql.sqlindex 359aa7ef85..86e6e5a409 100644--- a/scripts/postgresql/schema-1.2.0-postgresql.sql+++ b/scripts/postgresql/schema-1.2.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX table_column_version_info_idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX table_column_version_info_idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX table_column_version_info_idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';@@ -789,8 +789,8 @@ CREATE TABLE IF NOT EXISTS function_meta (PRIMARY KEY (function_id),UNIQUE (schema_id, function_name, deleted_at));-CREATE INDEX idx_function_meta_metalake_id ON function_meta (metalake_id);-CREATE INDEX idx_function_meta_catalog_id ON function_meta (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_metalake_id ON function_meta (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_catalog_id ON function_meta (catalog_id);COMMENT ON TABLE function_meta IS 'function metadata';COMMENT ON COLUMN function_meta.function_id IS 'function id';@@ -818,9 +818,9 @@ CREATE TABLE IF NOT EXISTS function_version_info (PRIMARY KEY (id),UNIQUE (function_id, version, deleted_at));-CREATE INDEX idx_function_version_metalake_id ON function_version_info (metalake_id);-CREATE INDEX idx_function_version_catalog_id ON function_version_info (catalog_id);-CREATE INDEX idx_function_version_schema_id ON function_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_function_version_metalake_id ON function_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_version_catalog_id ON function_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_version_schema_id ON function_version_info (schema_id);COMMENT ON TABLE function_version_info IS 'function version info';COMMENT ON COLUMN function_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-1.3.0-postgresql.sql b/scripts/postgresql/schema-1.3.0-postgresql.sqlindex 8efd931d94..d9aa68fca1 100644--- a/scripts/postgresql/schema-1.3.0-postgresql.sql+++ b/scripts/postgresql/schema-1.3.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX table_column_version_info_idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX table_column_version_info_idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX table_column_version_info_idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';@@ -861,8 +861,8 @@ CREATE TABLE IF NOT EXISTS function_meta (PRIMARY KEY (function_id),UNIQUE (schema_id, function_name, deleted_at));-CREATE INDEX idx_function_meta_metalake_id ON function_meta (metalake_id);-CREATE INDEX idx_function_meta_catalog_id ON function_meta (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_metalake_id ON function_meta (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_catalog_id ON function_meta (catalog_id);COMMENT ON TABLE function_meta IS 'function metadata';COMMENT ON COLUMN function_meta.function_id IS 'function id';@@ -890,9 +890,9 @@ CREATE TABLE IF NOT EXISTS function_version_info (PRIMARY KEY (id),UNIQUE (function_id, version, deleted_at));-CREATE INDEX idx_function_version_metalake_id ON function_version_info (metalake_id);-CREATE INDEX idx_function_version_catalog_id ON function_version_info (catalog_id);-CREATE INDEX idx_function_version_schema_id ON function_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_function_version_metalake_id ON function_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_version_catalog_id ON function_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_version_schema_id ON function_version_info (schema_id);COMMENT ON TABLE function_version_info IS 'function version info';COMMENT ON COLUMN function_version_info.id IS 'auto increment id';diff --git a/scripts/postgresql/schema-2.0.0-postgresql.sql b/scripts/postgresql/schema-2.0.0-postgresql.sqlindex 6c4d8c92a0..520a180fec 100644--- a/scripts/postgresql/schema-2.0.0-postgresql.sql+++ b/scripts/postgresql/schema-2.0.0-postgresql.sql@@ -160,9 +160,9 @@ CREATE TABLE IF NOT EXISTS table_column_version_info (PRIMARY KEY (id),UNIQUE (table_id, table_version, column_id, deleted_at));-CREATE INDEX table_column_version_info_idx_mid ON table_column_version_info (metalake_id);-CREATE INDEX table_column_version_info_idx_cid ON table_column_version_info (catalog_id);-CREATE INDEX table_column_version_info_idx_sid ON table_column_version_info (schema_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_mid ON table_column_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_cid ON table_column_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS table_column_version_info_idx_sid ON table_column_version_info (schema_id);COMMENT ON TABLE table_column_version_info IS 'table column version information';COMMENT ON COLUMN table_column_version_info.id IS 'auto increment id';@@ -889,8 +889,8 @@ CREATE TABLE IF NOT EXISTS function_meta (PRIMARY KEY (function_id),UNIQUE (schema_id, function_name, deleted_at));-CREATE INDEX idx_function_meta_metalake_id ON function_meta (metalake_id);-CREATE INDEX idx_function_meta_catalog_id ON function_meta (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_metalake_id ON function_meta (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_meta_catalog_id ON function_meta (catalog_id);COMMENT ON TABLE function_meta IS 'function metadata';COMMENT ON COLUMN function_meta.function_id IS 'function id';@@ -918,9 +918,9 @@ CREATE TABLE IF NOT EXISTS function_version_info (PRIMARY KEY (id),UNIQUE (function_id, version, deleted_at));-CREATE INDEX idx_function_version_metalake_id ON function_version_info (metalake_id);-CREATE INDEX idx_function_version_catalog_id ON function_version_info (catalog_id);-CREATE INDEX idx_function_version_schema_id ON function_version_info (schema_id);+CREATE INDEX IF NOT EXISTS idx_function_version_metalake_id ON function_version_info (metalake_id);+CREATE INDEX IF NOT EXISTS idx_function_version_catalog_id ON function_version_info (catalog_id);+CREATE INDEX IF NOT EXISTS idx_function_version_schema_id ON function_version_info (schema_id);COMMENT ON TABLE function_version_info IS 'function version info';COMMENT ON COLUMN function_version_info.id IS 'auto increment id';