Repository navigation
[Server] Add GEOMETRY and GEOGRAPHY column types #2369
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1792,6 +1792,8 @@ components: | |
| - 'NULL' | ||
| - USER_DEFINED_TYPE | ||
| - TABLE_TYPE | ||
| - GEOMETRY | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): The generated UI client cannot name either new column type
For example: A caller reading a column with Leave ui/src/types/api/catalog.gen.ts alone in this server PR. Regenerate it with the UI package's existing catalog generator in the stacked UI PR or in a standalone sync PR, and review the unrelated drift there. EvidenceThe OpenAPI enum gains two members. The checked-in enum generated from that exact file ends at TABLE_TYPE, and the UI types a column's type_name using it. I checked the generator command, its output, the generated Markdown model, and the upper UI layer, which changes ui-new rather than this generated file.
How it was checkedReproduced: head: Checked by 2 independent checks, which split: CONFIRMED, NITPICK Could the catalog types be regenerated alongside the spec change?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed — leaving UI client regeneration out of this server PR; UI updates live in #2373.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing to #2373 for the UI client regeneration; that works for me, so I'm happy to leave the generated UI client out of this server PR. Settled from our side, thanks. Please resolve this thread when you're ready.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): Reordering the new enum values later would silently change the type of stored functions
The change relies on For example: Swapping EvidenceThe DAO field has no How it was checkedChecked by 2 independent checks: CONFIRMED References:
Would a JDBC read of the stored ordinal in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That applies to the entire ColumnTypeName enum, not just GEOMETRY and GEOGRAPHY; the new values are appended at the end to preserve existing ordinals.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing out that the concern covers the whole enum and that the new values were appended. I checked at this head: the base-to-head change to Settled from our side, thanks. Please resolve this thread when you're ready.
timothyw553 marked this conversation as resolved.
Resolved
|
||
| - GEOGRAPHY | ||
| ColumnInfo: | ||
| type: object | ||
| properties: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,9 +1,10 @@ | ||||||
| #!/usr/bin/env bash | ||||||
|
timothyw553 marked this conversation as resolved.
Resolved
|
||||||
| # | ||||||
| # Fails when HEAD edits, deletes or renames a schema migration step, or a step's effect file, that | ||||||
| # exists on <base-ref>. Databases already ran those steps, and the effect files tell | ||||||
| # --upgrade-schema what they did, so a change to the schema must be a new step. | ||||||
| # Fails when a new step's version is not above every step on <base-ref> for that database: | ||||||
| # Fails when HEAD edits, deletes or renames a schema migration step (SQL or Java), the shared Java | ||||||
| # migration helper, or a step's effect file that exists on <base-ref>. Databases already ran those | ||||||
| # steps, and the effect files tell --upgrade-schema what they did, so a change to the schema must | ||||||
| # be a new step. | ||||||
| # Fails when a new step's version (SQL or Java) is not above every step on <base-ref>: | ||||||
| # databases already past it would never run it (Flyway refuses such a step). | ||||||
| # Also fails on any new step when <base-branch> is a release branch (branch-*): the step's number | ||||||
| # could clash with a different step on main, and the next upgrade would break. | ||||||
|
|
@@ -25,49 +26,62 @@ base_branch=${2:-} | |||||
|
|
||||||
| steps_dir=server/src/main/resources/db/migration | ||||||
| effects_dir=server/src/main/resources/schema-effects | ||||||
| java_steps_dir=server/src/main/java/io/unitycatalog/server/migrate | ||||||
|
timothyw553 marked this conversation as resolved.
Resolved
|
||||||
| java_step_glob="$java_steps_dir/V*.java" | ||||||
| java_helper="$java_steps_dir/DropRangeCheckMigration.java" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): Adding a database backend or fixing the range-check lookup will need an edit the migration-steps check refuses
The stored part of a Java step is its checksum, Cost of keeping it: If this merges as is, adding a fourth The helper is also the obvious tool for the 8 other unnamed ordinal CHECKs in the baseline ( Freeze only the EvidenceThe script adds the helper to the frozen M/D/R/T list. The helper imports the unfrozen
How it was checkedChecked by 1 independent check: NITPICK References:
Would freezing only the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Freezing DropRangeCheckMigration.java is intentional so merged Java migration behavior cannot silently drift; a future backend addition can explicitly update the guard if needed.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining the intent: with the helper frozen on purpose, a future backend addition has to edit the guard explicitly, and I'm fine with that. I checked the head: Settled from our side, thanks. Please resolve this thread when you're ready. |
||||||
|
|
||||||
| if ! merge_base=$(git merge-base "$1" HEAD); then | ||||||
| echo "No merge base between $1 and HEAD; fetch more history." >&2 | ||||||
| exit 2 | ||||||
| fi | ||||||
|
|
||||||
| changed=$(git diff --diff-filter=MDRT --name-status "$merge_base" HEAD -- "$steps_dir" "$effects_dir") | ||||||
| changed=$(git diff --diff-filter=MDRT --name-status "$merge_base" HEAD -- \ | ||||||
| "$steps_dir" "$effects_dir" "$java_step_glob" "$java_helper") | ||||||
| if [[ -n "$changed" ]]; then | ||||||
| echo "These merged migration steps or effect files changed since $1:" >&2 | ||||||
| echo "These merged migration steps, helpers, or effect files changed since $1:" >&2 | ||||||
| echo "$changed" >&2 | ||||||
| echo "Merged steps can't change; add a new step under $steps_dir/<db>/ instead." >&2 | ||||||
| echo "Merged steps can't change; add a new step instead." >&2 | ||||||
| exit 1 | ||||||
| fi | ||||||
| echo "No merged migration step or effect file changed since $1." | ||||||
| echo "No merged migration step, helper, or effect file changed since $1." | ||||||
|
|
||||||
| # A release branch takes no new steps at all, so say that before checking their numbers. | ||||||
| added=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- "$steps_dir" "$effects_dir") | ||||||
| added=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- \ | ||||||
| "$steps_dir" "$effects_dir" "$java_step_glob") | ||||||
| if [[ -n "$added" && "$base_branch" == branch-* ]]; then | ||||||
| echo "These migration steps are new on the release branch $base_branch:" >&2 | ||||||
| echo "$added" >&2 | ||||||
| echo "Release branches take no new steps; add the step on main." >&2 | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| # The version of a step file name V<version>__<description>.sql. | ||||||
| version_of() { basename "$1" | sed -n 's/^V\([0-9]*\)__.*/\1/p'; } | ||||||
| # The version of a step file name V<version>__<description>.(sql|java) or effect file V<version>.txt. | ||||||
| version_of_step() { basename "$1" | sed -n 's/^V\([0-9]*\)__.*/\1/p'; } | ||||||
| version_of_effect() { basename "$1" | sed -n 's/^V\([0-9]*\)\.txt$/\1/p'; } | ||||||
|
|
||||||
| added_steps=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- "$steps_dir") | ||||||
| # Highest step version on <base-ref> across SQL steps, Java steps, and schema-effects. | ||||||
| highest_on_base() { | ||||||
| { | ||||||
| git ls-tree -r --name-only "$1" -- "$steps_dir/" "$java_step_glob" \ | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): The version-order guard overlooks Java source filenames
For example: With SQL
Suggested change
EvidenceThe quoted V*.java argument lists zero paths under git ls-tree at this head, while listing its directory returns both Java steps. highest_on_base separately reads effect files, and its regression fixture writes V21.txt alongside the Java source. In an isolated base containing SQL V17 and Java V21 without V21.txt, the script accepted SQL V19.
How it was checkedReproduced: head: with the fix: Base has V17 sql, V18 java, V20 sql, plus a V22 Java step with no effect file. A new SQL step V21 is added above the old highest (20) but below V22. Unmodified script exits 0, so it accepts an out-of-order step: git ls-tree does not expand the V*.java pathspec, and the version ceiling came only from effect files. Fix (list the Java directory, keep the version_of_step filter) turns it green, and the other 7 tests still pass. The script is identical at base and PR head (no diff to dev/check-migration-steps.sh), so the code predates this PR and a base run was not needed. Test is committed as ecdc2cd without the fix; the fix was reverted. Only H2/no database involved. Reach is limited: the repo requires an effect file per step, so only a Java step lacking one triggers it. Nit severity stands.
Checked by 1 independent check: CONFIRMED References:
Could we list the migration directory and let
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch on git ls-tree not expanding V*.java; effect files already cover the version check for merged Java steps, and we can clean that up in a follow-up or next touch.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining why the effect files cover this. I checked it at the head: the glob does miss the Java steps, but a merged Java step always has an effect file, so the version check gives the right result in practice. Cleaning it up in a follow-up or the next time the script is touched is fine with me. Settled from our side, thanks. Please resolve this thread when you're ready.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): The migration order check can miss the highest Java step
For example: With SQL In dev/check-migration-steps.sh, replace the quoted "$java_step_glob" pathspec in both EvidenceThe script claims to read the highest version across Java sources, SQL, and effects. Its quoted V*.java path produces no Java paths from git ls-tree. The regression fixture adds a same-version effect, so it exercises the fallback. In a temporary repository with SQL V17 and Java V21 without its effect, the actual script accepted new SQL V19.
How it was checkedReproduced: head: with the fix: Base has SQL V17/V20-free Java V21 without a V21 effect file; the new SQL V21 step is accepted on head (script exit 0, should be 1) because the quoted glob passed to git ls-tree matches nothing, so the highest on base falls back to 20. The fix (list the Java directory, filter with version_of_step) turns it green and the other 7 tests still pass. The script already existed at base 3317ea3 and was changed in this PR, so I did not run a base comparison. Reachability: a merged Java step always has an effect file (SchemaMigrator.expected throws 'no effect file' for a step without one; MigrationStepRulesTest checks it), so the effect-file scan already supplies the Java version. With a realistic base the existing test refusesSqlStepNumberedBelowExistingJavaStep passes. The bug is real but masked in practice. Test is H2-independent (shell script and git only), so no database matrix applies.
Checked by 2 independent checks, which split: CONFIRMED, DISPROVED References:
Could the script list the Java directory and let
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate of discussion_r4744726774 — see reply there.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing to the earlier thread on the same line. I re-checked at this head. |
||||||
| | while read -r f; do version_of_step "$f"; done | ||||||
| git ls-tree -r --name-only "$1" -- "$effects_dir/" \ | ||||||
| | while read -r f; do version_of_effect "$f"; done | ||||||
| } | awk '/^[0-9]+$/ { print $1 + 0 }' | sort -n | tail -n 1 | ||||||
| } | ||||||
|
|
||||||
| highest=$(highest_on_base "$1") | ||||||
|
|
||||||
| added_steps=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- \ | ||||||
| "$steps_dir" "$java_step_glob") | ||||||
| for step in $added_steps; do | ||||||
| folder=$(dirname "$step") | ||||||
| highest=$(git ls-tree --name-only "$1" -- "$folder/" \ | ||||||
| | while read -r f; do version_of "$f"; done | sort -n | tail -n 1) | ||||||
| version=$(version_of "$step") | ||||||
| version=$(version_of_step "$step") | ||||||
| if [[ ! "$version" =~ ^[0-9]+$ ]]; then | ||||||
| echo "The new step $step has a version that is not a whole number." >&2 | ||||||
| echo "Name it V<number>__<description>.sql." >&2 | ||||||
| echo "Name it V<number>__<description>.sql or V<number>__<description>.java." >&2 | ||||||
| exit 1 | ||||||
| fi | ||||||
| # 10# keeps bash from reading a leading zero (V08) as octal. | ||||||
| version=$((10#$version)) | ||||||
| if [[ -n "$highest" ]]; then | ||||||
| highest=$((10#$highest)) | ||||||
| fi | ||||||
| if [[ -n "$highest" && "$version" -le "$highest" ]]; then | ||||||
| echo "The new step $step is not above step $highest, the highest on $1." >&2 | ||||||
| echo "Renumber it above every merged step." >&2 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,158 @@ | ||||||
| package io.unitycatalog.server.migrate; | ||||||
|
|
||||||
| import io.unitycatalog.server.migrate.SchemaMigrator.DatabaseKind; | ||||||
| import java.sql.Connection; | ||||||
| import java.sql.PreparedStatement; | ||||||
| import java.sql.ResultSet; | ||||||
| import java.sql.SQLException; | ||||||
| import java.sql.Statement; | ||||||
| import java.util.ArrayList; | ||||||
| import java.util.List; | ||||||
| import java.util.Locale; | ||||||
| import java.util.Objects; | ||||||
| import javax.sql.DataSource; | ||||||
| import org.flywaydb.core.api.migration.BaseJavaMigration; | ||||||
| import org.flywaydb.core.api.migration.Context; | ||||||
| import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | ||||||
|
|
||||||
| /** | ||||||
| * Drops an unnamed ordinal-range {@code CHECK} constraint (such as {@code BETWEEN 0 AND 21}) after | ||||||
| * a prior step has added its wider replacement. Looks up the database-generated constraint name at | ||||||
| * runtime so the step works on fresh databases and on databases whose checks were repaired or | ||||||
| * renamed. | ||||||
| */ | ||||||
| abstract class DropRangeCheckMigration extends BaseJavaMigration { | ||||||
|
|
||||||
| private static final Logger LOGGER = LoggerFactory.getLogger(DropRangeCheckMigration.class); | ||||||
|
|
||||||
| private static final String STANDARD_LOOKUP = | ||||||
| """ | ||||||
| SELECT tc.constraint_name | ||||||
| FROM information_schema.table_constraints tc | ||||||
| JOIN information_schema.check_constraints cc | ||||||
| ON cc.constraint_schema = tc.constraint_schema | ||||||
| AND cc.constraint_name = tc.constraint_name | ||||||
| WHERE tc.constraint_type = 'CHECK' | ||||||
| AND tc.table_schema = %s | ||||||
| AND LOWER(tc.table_name) = ? | ||||||
| AND cc.check_clause = ? | ||||||
| """; | ||||||
|
|
||||||
| private static final String POSTGRES_LOOKUP = | ||||||
| """ | ||||||
| SELECT con.conname | ||||||
| FROM pg_constraint con | ||||||
| JOIN pg_class c ON c.oid = con.conrelid | ||||||
| JOIN pg_namespace n ON n.oid = c.relnamespace | ||||||
| WHERE con.contype = 'c' | ||||||
| AND n.nspname = current_schema() | ||||||
| AND c.relname = ? | ||||||
| AND pg_get_constraintdef(con.oid) = ? | ||||||
| """; | ||||||
|
|
||||||
| private final String table; | ||||||
| private final String column; | ||||||
| private final int min; | ||||||
| private final int max; | ||||||
|
|
||||||
| DropRangeCheckMigration(String table, String column, int min, int max) { | ||||||
| this.table = table.toLowerCase(Locale.ROOT); | ||||||
| this.column = column.toLowerCase(Locale.ROOT); | ||||||
| this.min = min; | ||||||
| this.max = max; | ||||||
| } | ||||||
|
|
||||||
| String table() { | ||||||
| return table; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public Integer getChecksum() { | ||||||
| return Objects.hash(table, column, min, max); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Preflight check called before running pending steps so duplicate or missing CHECK constraints | ||||||
| * fail before an earlier step (such as adding the wider CHECK) commits. Returns the matched | ||||||
| * constraint name so simulation can account for its removal. | ||||||
| */ | ||||||
| String verifySingleMatch(DataSource dataSource, DatabaseKind kind) { | ||||||
| try (Connection connection = dataSource.getConnection()) { | ||||||
| return requireSingleConstraintName(connection, kind); | ||||||
| } catch (SQLException e) { | ||||||
| throw new IllegalStateException( | ||||||
| "Could not check existing CHECK constraints on %s: %s".formatted(table, e.getMessage()), | ||||||
| e); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public void migrate(Context context) throws SQLException { | ||||||
| Connection connection = context.getConnection(); | ||||||
| DatabaseKind kind = DatabaseKind.of(connection); | ||||||
| String name = requireSingleConstraintName(connection, kind); | ||||||
|
timothyw553 marked this conversation as resolved.
Resolved
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): The Java steps execute a lookup as well as the schema change The description counts one statement per step. Each Java step executes two SQL operations, while only the For example:
Suggested change
EvidenceThe description counts each Java step as a single SQL statement. Each first executes a prepared lookup and then executes the ALTER. The statement recorder excludes prepared statements, which explains how the one-statement assertion and this implementation coexist.
How it was checkedChecked by 1 independent check: NITPICK Could the description call these four steps with one schema-changing statement each?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description refers to one schema-changing DDL statement per step, which is accurate.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining the intent: one schema-changing statement per step is the right idea, and since this is only a wording nit on the description, I'm happy to leave it as is (if you touch the text again, "schema-changing statement" would match what the Java steps do). Settled from our side, thanks. Please resolve this thread when you're ready. |
||||||
| String dropSql = dropStatement(kind, name); | ||||||
| try (Statement statement = connection.createStatement()) { | ||||||
| statement.execute(dropSql); | ||||||
| } | ||||||
| LOGGER.info("Dropped old range check {} on {}.{} ({}..{})", name, table, column, min, max); | ||||||
| } | ||||||
|
|
||||||
| private String requireSingleConstraintName(Connection connection, DatabaseKind kind) | ||||||
| throws SQLException { | ||||||
| String expectedClause = expectedClause(kind); | ||||||
| List<String> names = findConstraintNames(connection, kind, expectedClause); | ||||||
| if (names.isEmpty()) { | ||||||
| throw new IllegalStateException( | ||||||
| ("Expected exactly one CHECK constraint matching %s on %s, found []. Restore the missing" | ||||||
| + " CHECK constraint or restore the backup, then run --upgrade-schema again.") | ||||||
| .formatted(expectedClause, table)); | ||||||
| } | ||||||
| if (names.size() > 1) { | ||||||
| throw new IllegalStateException( | ||||||
| ("Expected exactly one CHECK constraint matching %s on %s, found %s. Drop the duplicate" | ||||||
| + " CHECK constraint(s) so only one remains, or restore the backup, then run" | ||||||
| + " --upgrade-schema again.") | ||||||
| .formatted(expectedClause, table, names)); | ||||||
| } | ||||||
| return names.get(0); | ||||||
| } | ||||||
|
|
||||||
| private String expectedClause(DatabaseKind kind) { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): The old-check lookup and the schema snapshot can disagree about which constraint is the 0..21 check
The effect file Cost of keeping it: If this merges as is, each future range-check drop, and each change to the snapshot's normalization, has to be copied into On MySQL the two already differ: a NOT ENFORCED 0..21 check is a different entry in the snapshot, but the lookup still counts it as a match. Have Evidence
How it was checkedChecked by 1 independent check: NITPICK Could the step look up names by the snapshot entry instead, so there is one definition of a check's spelling per dialect?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving DropRangeCheckMigration self-contained keeps the drop lookup simple and explicit; on MySQL a disabled check is already caught by SchemaSnapshot's post-upgrade check.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing to the MySQL snapshot check: I confirmed on MySQL 8 that with the old 0..21 check set to NOT ENFORCED at V16, the upgrade is refused and the schema version stays at 16, so a self-contained lookup is fine and I'm happy to leave it as is. One small wording note: the refusal comes from the pre-upgrade schema comparison, not a post-upgrade one. Settled from our side, thanks. Please resolve this thread when you're ready. |
||||||
| return switch (kind) { | ||||||
| case H2 -> "\"%s\" BETWEEN %d AND %d".formatted(column.toUpperCase(Locale.ROOT), min, max); | ||||||
| case MYSQL -> "(`%s` between %d and %d)".formatted(column, min, max); | ||||||
| case POSTGRESQL -> "CHECK (((%1$s >= %2$d) AND (%1$s <= %3$d)))".formatted(column, min, max); | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| private List<String> findConstraintNames( | ||||||
| Connection connection, DatabaseKind kind, String expectedClause) throws SQLException { | ||||||
| String lookupSql = | ||||||
| switch (kind) { | ||||||
| case H2 -> STANDARD_LOOKUP.formatted("CURRENT_SCHEMA"); | ||||||
| case MYSQL -> STANDARD_LOOKUP.formatted("DATABASE()"); | ||||||
| case POSTGRESQL -> POSTGRES_LOOKUP; | ||||||
| }; | ||||||
| List<String> names = new ArrayList<>(); | ||||||
| try (PreparedStatement ps = connection.prepareStatement(lookupSql)) { | ||||||
| ps.setString(1, table); | ||||||
| ps.setString(2, expectedClause); | ||||||
| try (ResultSet rs = ps.executeQuery()) { | ||||||
| while (rs.next()) { | ||||||
| names.add(rs.getString(1)); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| return names; | ||||||
| } | ||||||
|
|
||||||
| private String dropStatement(DatabaseKind kind, String name) { | ||||||
| return switch (kind) { | ||||||
| case H2, POSTGRESQL -> | ||||||
| "ALTER TABLE %s DROP CONSTRAINT \"%s\"".formatted(table, name.replace("\"", "\"\"")); | ||||||
| case MYSQL -> "ALTER TABLE %s DROP CHECK `%s`".formatted(table, name.replace("`", "``")); | ||||||
| }; | ||||||
| } | ||||||
| } | ||||||
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.
Blocker: One geo function prevents Python clients from listing existing functions
AI core pins
unitycatalog-clientto0.4.0in its lockfile. That client decodes every function'sdata_typeagainst a closed enum, so one geo return type makes the entire page unreadable. This is one bug class: Adding a value to a spec enum breaks strict generated clients already released, because the Python generator has no unknown-enum fallback. The same issue appears in api/all.yaml:1793 (ColumnInfo.type_name is the same enum on tables. The native createTable now accepts type_name GEOMETRY, and older Python clients' get_table and list_tables fail); build.sbt:322 (The Python generator config lacks the enumUnknownDefaultCase setting that the Java config has. The regenerated Python client is still strict, so the next enum v).For example: A Python caller lists a schema containing an
INTfunction successfully. Once the same page includes aGEOMETRYfunction, the HTTP response is still200, butlist_functionsraisesValidationErrorand returns neither function.State in the PR description, and in the release notes, that strict generated clients (Python unitycatalog-client <= 0.4.x, which AI core pins) cannot decode a list page that contains a geo-typed function. Release a regenerated Python client and widen ai/core's pin in a follow-up, or in the stacked layer that carries the client changes, before these values reach users.
Evidence
The new enum values appear in an authorized list response, as the head's SDK test asserts. AI core locks unitycatalog-client 0.4.0 and calls its typed list method before returning any functions. I inspected that release's model and called FunctionsApi.list_functions against a local HTTP 200 endpoint. An INT-only page decoded. Adding GEOMETRY caused ValidationError before the existing row could be returned. I also verified GEOGRAPHY fails in the same decoder.
api/all.yaml:1775-1779server/src/main/java/io/unitycatalog/server/service/FunctionService.java:90-96server/src/test/java/io/unitycatalog/server/sdk/function/SdkFunctionCRUDTest.java:282-302ai/core/uv.lock:2372-2375ai/core/src/unitycatalog/ai/core/client.py:1027-1035How it was checked
Checked by 2 independent checks, which split: CONFIRMED, CONTESTED
References:
Could we release and select a compatible Python reader before these values appear in shared schemas?
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.
This is inherent to adding any new ColumnTypeName enum value in api/all.yaml; callers using the new types need a regenerated client, and existing databases without geo functions are unaffected.
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.
Thanks for spelling out that any new
ColumnTypeNamevalue affects strict clients and that databases with no geo values are unaffected, which matches what I saw when decoding with the released 0.4.0 client. I'll go with that as it stands.Settled from our side, thanks. Please resolve this thread when you're ready.