Skip to content

fix: case insensitivity of catalog endpoints - #1338

Merged
c-thiel merged 15 commits into
mainfrom
mz/fix-case-insensitivity
Sep 22, 2025
Merged

c-thiel merged 15 commits into
mainfrom
mz/fix-case-insensitivity

Conversation

@mooori

@mooori mooori commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Closes #1319

It seems like there are no other getters where collation could cause a similar issue, or did I miss something? In particular namespaces should not be affected as there is no corresponding namespace_idents_to_ids function. Besides tabulars and namespaces, I think collation is applied nowhere else.

Regarding the modification of the db query: indices generated on the Rust side would need to be plumbed into a new, non-static CTE at the beginning of the query. Going instead with the jsonb encoding of Vec<Vec<String>> appeared to be the simpler approach. As a positive side effect, the whole query is static now.

Summary by CodeRabbit

  • New Features
    • Case-insensitive lookups for table and namespace names, ensuring consistent results regardless of input casing.
  • Bug Fixes
    • Resolved inconsistencies when querying the same object with different letter casing, reducing missed or duplicate results.
  • Tests
    • Added tests validating case-insensitive identifier resolution and correct mapping to the same underlying object.
  • Chores / Database
    • Added a database helper to convert JSONB arrays to text[] (migration) to improve query input handling.

@coderabbitai

coderabbitai Bot commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Replaces an old SQLx query descriptor with a new, richer descriptor using JSONB, UNNEST, and LATERAL; adds a migration function jsonb_to_textarr(jsonb) RETURNS text[]; refactors Postgres tabular lookup to a static SQL path, adds list_flags to tabular_idents_to_ids, adjusts nullability handling, and adds a case-insensitivity test.

Changes

Cohort / File(s) Summary
SQLx descriptors
.sqlx/query-384024b34f73ada1c5b706c761bb8e5fe5ed3a5874822e3582103728ecb2d2b5.json, .sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json
Removed the old 3-parameter PostgreSQL SQLx descriptor; added a new 6-parameter descriptor that uses LATERAL, jsonb_array_elements/ordinality and UNNEST to align input namespaces/names/types and filter by warehouse/status/deleted/metadata.
Migration
crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql
Adds SQL function jsonb_to_textarr(jsonb) RETURNS text[] implemented with jsonb_array_elements_text(... ) WITH ORDINALITY and array_agg(... ORDER BY ord).
Postgres tabular mapping
crates/lakekeeper/src/implementations/postgres/tabular/mod.rs
Replaces QueryBuilder/dynamic-filtering with a static SQL approach that serializes inputs (JSONB + arrays), uses UNNEST/LATERAL and the new jsonb_to_textarr, changes TabularRow fields for nullable namespace/tabular_name, adds list_flags param to tabular_idents_to_ids, removes MAX_PARAMETERS and dynamic filter helpers, and updates result mapping/filling logic.
Tests
crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs
Adds sqlx test test_to_ids_case_insensitivity verifying case-insensitive identifier resolution and consistent mapping of different-cased idents to the same underlying table ID.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Service as tabular_idents_to_ids
  participant DB as Postgres

  Caller->>Service: tabular_idents_to_ids(warehouse_id, idents, list_flags, catalog_state)
  note right of Service #DDFFDD: Build ns_names, t_names, t_typs\nSerialize ns_names -> ns_names_json
  Service->>DB: Execute static SQL (LATERAL + UNNEST + jsonb_to_textarr)\nparams: [Uuid, Jsonb, text[], tabular_type[], Bool, Bool]
  DB-->>Service: Rows (tabular_id, namespace?, tabular_name?, typ)
  note right of Service #FFFBCC: Validate non-null namespace/name\nParse namespace identifiers\nMap to HashMap<TabularIdentOwned, Option<TabularId>>
  Service-->>Caller: Map of requested idents -> optional IDs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through schemas, ears held high,
Unnesting names that flutter by.
JSON turns to ordered text,
Casefold paths now find their next.
A lateral leap, a tidy map—
I nibble bugs, then take a nap. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: case insensitivity of catalog endpoints" is concise and accurately summarizes the primary change—addressing case-insensitivity in catalog (tabular) endpoints—without extraneous detail, making it clear to reviewers what the main intent is.
Linked Issues Check ✅ Passed The changes address the objective in [#1319] by encoding input name lists as JSONB and switching to a static SQL path (including a new jsonb_to_textarr migration, updated SQLx descriptor, and modified tabular lookup logic) and by adding a unit test (test_to_ids_case_insensitivity) that verifies the intended case-insensitive behavior, so the coding requirements of the linked issue are met.
Out of Scope Changes Check ✅ Passed All changes are focused on implementing case-insensitive tabular lookups and their supporting artifacts (migration, new query descriptor, refactor from dynamic QueryBuilder to static SQL, and tests); the only notable wider change is a localized pub(crate) signature update adding list_flags to tabular_idents_to_ids, which appears necessary for the new approach, so I do not observe out-of-scope modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mooori

mooori commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 16, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@mooori
mooori marked this pull request as ready for review September 16, 2025 14:39
@mooori

mooori commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 16, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1)

1-3: Mark function as IMMUTABLE/STRICT/PARALLEL SAFE and avoid NULL for empty arrays.

This is deterministic and safe to parallelize. Returning an empty array instead of NULL simplifies callers.

Apply:

-CREATE FUNCTION jsonb_to_textarr(jsonb) RETURNS text[] AS $$
-    SELECT array_agg(txt) FROM jsonb_array_elements_text($1) txt;
-$$ LANGUAGE SQL;
+CREATE FUNCTION jsonb_to_textarr(jsonb) RETURNS text[]
+LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE
+AS $$
+    SELECT COALESCE(array_agg(txt), ARRAY[]::text[])
+    FROM jsonb_array_elements_text($1) AS txt;
+$$;
crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1)

1378-1445: Great coverage for case-insensitive matching across mixed-case idents.

Nice use of different casings and extra noise table; asserts validate both key casing and ID equality.

Consider adding a sibling test for resolve_table_ident (single lookup) with mismatched case to lock in parity with the batch path.

crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4)

184-192: Avoid Option by asserting non-nullability in the query mapping.

You already filter out NULLs in SQL; map directly to non-null fields to simplify runtime checks.

Apply:

-#[derive(Debug, FromRow)]
-struct TabularRow {
-    tabular_id: Uuid,
-    // Despite `IS NOT NULL` filter sqlx thinks column selected from input is nullable.
-    namespace: Option<Vec<String>>,
-    // Despite `IS NOT NULL` filter sqlx thinks column selected from input is nullable.
-    tabular_name: Option<String>,
+#[derive(Debug, FromRow)]
+struct TabularRow {
+    tabular_id: Uuid,
+    namespace: Vec<String>,
+    tabular_name: String,
     #[sqlx(rename = "typ: TabularType")]
     typ: TabularType,
 }

And in the SELECT aliases (Lines 247-251), inform sqlx about types:

-            in_ns.name as "namespace",
-            in_t.name as tabular_name,
+            in_ns.name as "namespace: Vec<String>",
+            in_t.name as "tabular_name!",

Then drop the unwrap checks at Lines 284-297.

-        let namespace = in_namespace.ok_or_else(|| { ... })?;
-        let name = in_tabular_name.ok_or_else(|| { ... })?;
+        let namespace = in_namespace;
+        let name = in_tabular_name;

235-242: Prefer passing typed Json for clarity.

Using sqlx::types::Json makes the intent explicit and avoids relying on as _ casts.

Apply:

-    let ns_names_json = serde_json::to_value(&ns_names).map_err(|e| {
+    let ns_names_json = sqlx::types::Json(&ns_names);
+    // serde step no longer needed

And in the bind list (Lines 265-271):

-        ns_names_json as _,
+        ns_names_json,

247-265: Minor: remove redundant NULL guards or keep them documented.

Given inputs originate from Rust (non-null) and you filter via IS NOT NULL, these WHERE clauses are defensive. Either keep with a brief comment or drop to reduce noise.


316-321: Filling gaps with None is correct; consider early return optimization.

If rows.len() == tables.len(), you can skip the second pass.

-    if table_map.len() < tables.len() {
+    if table_map.len() < tables.len() {
         for table in tables {
             table_map.entry(table.into()).or_insert(None);
         }
     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba99043 and a6dabd8.

📒 Files selected for processing (5)
  • .sqlx/query-384024b34f73ada1c5b706c761bb8e5fe5ed3a5874822e3582103728ecb2d2b5.json (0 hunks)
  • .sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json (1 hunks)
  • crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • .sqlx/query-384024b34f73ada1c5b706c761bb8e5fe5ed3a5874822e3582103728ecb2d2b5.json
🧰 Additional context used
🧬 Code graph analysis (2)
crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (3)
crates/lakekeeper/src/implementations/postgres/warehouse.rs (1)
  • initialize_warehouse (762-811)
crates/lakekeeper/src/implementations/postgres/namespace.rs (1)
  • initialize_namespace (631-658)
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)
  • table_idents_to_ids (200-207)
crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (2)
crates/lakekeeper/src/implementations/postgres/user.rs (2)
  • sqlx (112-149)
  • sqlx (248-268)
crates/iceberg-ext/src/catalog/rest/error.rs (2)
  • new (232-244)
  • internal (161-172)
🔇 Additional comments (2)
crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (1)

215-233: Good: capacity preallocation and single-pass extraction.

The fold with with_capacity aligns the three vectors by construction; reduces reallocs.

.sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json (1)

1-72: Static query shape looks correct; verify collation-backed indexes exist.

Automated search returned no matches — confirm in migrations or the live DB that tabular.name and namespace.namespace_name use the intended case‑insensitive ICU collation and that matching indexes (or expression indexes created with COLLATE) exist so equality joins can use indexes.

Quick checks to run locally:

  • rg -nC2 -e 'COLLATE' -e 'CREATE COLLATION' -e 'CREATE INDEX.\b(tabular|namespace)\b.\bname\b'
  • psql -c "SELECT column_name, collation_name FROM information_schema.columns WHERE table_name IN ('tabular','namespace') AND column_name IN ('name','namespace_name');" && psql -c "SELECT indexname, indexdef FROM pg_indexes WHERE tablename IN ('tabular','namespace');"

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1)

1-3: Make function deterministic and preserve array order.

Mark as IMMUTABLE/STRICT/PARALLEL SAFE and use WITH ORDINALITY + ORDER BY to guarantee stable element order. Optional: COALESCE to return empty array instead of NULL for empty inputs.

-CREATE FUNCTION jsonb_to_textarr(jsonb) RETURNS text[] AS $$
-    SELECT array_agg(txt) FROM jsonb_array_elements_text($1) txt;
-$$ LANGUAGE SQL;
+CREATE FUNCTION jsonb_to_textarr(jsonb) RETURNS text[] AS $$
+    SELECT COALESCE(array_agg(val ORDER BY ord), ARRAY[]::text[])
+    FROM jsonb_array_elements_text($1) WITH ORDINALITY AS e(val, ord);
+$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE;
crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (3)

194-205: Fix doc typo and tighten phrasing.

Small wording nit.

-/// In line with that, querying both `table1` and `TABLE1` returns a map with two entries, both
-/// both being the same table id.
+/// In line with that, querying both `table1` and `TABLE1` returns a map with two entries,
+/// both mapping to the same table id.

215-232: Defensive invariant: input vectors must stay aligned.

Add a debug assertion to catch accidental mismatches early.

     let (ns_names, t_names, t_typs) = tables.iter().fold(
         (
             Vec::with_capacity(tables.len()),
             Vec::with_capacity(tables.len()),
             Vec::with_capacity(tables.len()),
         ),
         |(mut ns_names, mut t_names, mut t_typs), t| {
             let TableIdent { namespace, name } = t.to_table_ident_tuple();
             let typ: TabularType = t.into();
             ns_names.push(namespace.as_ref());
             t_names.push(name);
             t_typs.push(typ);
             (ns_names, t_names, t_typs)
         },
     );
+    debug_assert!(ns_names.len() == t_names.len() && t_names.len() == t_typs.len());

243-271: Consider qualifying the function and minimizing planner surprises.

Minor: schema‑qualify jsonb_to_textarr (e.g., public.jsonb_to_textarr) to avoid search_path issues in multi‑schema deployments.

crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1)

1378-1445: Strengthen assertions and clean up.

  • Capture the created table and assert the returned id equals it (not just is_some()).
  • Remove the commented //tables.clone().
-        let _ = initialize_table(
+        let created = initialize_table(
             warehouse_id,
             state.clone(),
             false,
             Some(namespace_lower.clone()),
             Some(table_ident_lower.name.clone()),
         )
         .await;
@@
-        let existing = table_idents_to_ids(
+        let existing = table_idents_to_ids(
             warehouse_id,
-            //tables.clone(),
             HashSet::from([&table_ident_upper]),
             ListFlags::default(),
             &state.read_pool(),
         )
         .await
         .unwrap();
         assert_eq!(existing.len(), 1);
-        // The queried ident must be the key in the map.
-        assert!(existing.get(&table_ident_upper).unwrap().is_some());
+        assert_eq!(
+            existing.get(&table_ident_upper),
+            Some(&Some(created.table_id))
+        );
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba99043 and a6dabd8.

📒 Files selected for processing (5)
  • .sqlx/query-384024b34f73ada1c5b706c761bb8e5fe5ed3a5874822e3582103728ecb2d2b5.json (0 hunks)
  • .sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json (1 hunks)
  • crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • .sqlx/query-384024b34f73ada1c5b706c761bb8e5fe5ed3a5874822e3582103728ecb2d2b5.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-05T15:17:37.543Z
Learnt from: mooori
PR: lakekeeper/lakekeeper#1254
File: .sqlx/query-7ebda80ee60f12b9723e555f1d146e815a906481dd28c2986ec11cb1185b00aa.json:0-0
Timestamp: 2025-09-05T15:17:37.543Z
Learning: When reviewing .sqlx query descriptors in PRs with focused scope (like adding warehouse_id for multi-warehouse support), defer query optimization suggestions to follow-up issues if the existing pattern was functional before the changes, even if the query structure could be improved.

Applied to files:

  • .sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json
🔇 Additional comments (2)
.sqlx/query-3e7d66b9daa8381ad6073175b60e19e99a0040f631413945c5d4e3e05abe63d0.json (1)

1-72: Descriptor shape LGTM; matches the static SQL.

Inputs/outputs and nullability align with TabularRow. Ensure cargo sqlx prepare --check passes on CI.

crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (1)

185-192: Nullable fields approach is fine.

Accepting Option<Vec<String>>/Option<String> here is a pragmatic workaround for SQLx’s nullability inference on derived columns.

@mooori

mooori commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai incremental

@coderabbitai

coderabbitai Bot commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

@mooori I'll perform an incremental review of the changes made since the last review.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1)

1-4: Schema-qualify the function to avoid search_path surprises.

Explicitly create it in a known schema (e.g., public) to prevent production/session search_path drift from breaking the call sites.

Apply this diff:

-CREATE FUNCTION jsonb_to_textarr(jsonb) RETURNS text[] AS $$
+CREATE FUNCTION public.jsonb_to_textarr(jsonb) RETURNS text[] AS $$
     SELECT array_agg(val ORDER BY ord)
     FROM jsonb_array_elements_text($1) WITH ORDINALITY AS e(val, ord);
 $$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE;
crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4)

181-192: Drop Option<> by asserting NOT NULL in the SELECT; remove runtime checks.

These fields originate from inputs and are filtered non-null; we can encode that in the query to simplify the model and avoid defensive unwraps.

Apply this diff:

 #[derive(Debug, FromRow)]
 struct TabularRow {
     tabular_id: Uuid,
-    // Despite `IS NOT NULL` filter sqlx thinks column selected from input is nullable.
-    namespace: Option<Vec<String>>,
-    // Despite `IS NOT NULL` filter sqlx thinks column selected from input is nullable.
-    tabular_name: Option<String>,
+    namespace: Vec<String>,
+    tabular_name: String,
     // apparently this is needed, we need 'as "typ: TabularType"' in the query else the select won't
     // work, but that apparently aliases the whole column to "typ: TabularType"
     #[sqlx(rename = "typ: TabularType")]
     typ: TabularType,
 }
-            in_ns.name as "namespace",
-            in_t.name as tabular_name,
+            in_ns.name as "namespace!: Vec<String>",
+            in_t.name as "tabular_name!: String",
-        namespace: in_namespace,
-        tabular_name: in_tabular_name,
+        namespace,
+        tabular_name: name,
         typ,
     } in rows
     {
-        let namespace = in_namespace.ok_or_else(|| {
-            ErrorModel::internal(
-                "Namespace name should not be null",
-                "InternalDatabaseError",
-                None,
-            )
-        })?;
-        let name = in_tabular_name.ok_or_else(|| {
-            ErrorModel::internal(
-                "Tabular name should not be null",
-                "InternalDatabaseError",
-                None,
-            )
-        })?;
         let namespace = try_parse_namespace_ident(namespace)?;

Also applies to: 248-250, 284-297


234-242: Avoid building an intermediate serde_json::Value; pass JSON via sqlx::types::Json.

This trims an allocation and removes an error branch.

-    // Encoding `ns_names` as json is a workaround for `sqlx` not supporting `Vec<Vec<String>>`.
-    let ns_names_json = serde_json::to_value(&ns_names).map_err(|e| {
-        ErrorModel::internal(
-            "Error json encoding namespace names",
-            "EncodingError",
-            Some(Box::new(e)),
-        )
-    })?;
+    // Encoding `ns_names` as JSONB (sqlx wraps serialization).
+    let ns_names_json = sqlx::types::Json(&ns_names);

And keep the bind as:

-        ns_names_json as _,
+        ns_names_json,

Note: sqlx will bind Json to jsonb for this placeholder as described by the prepared descriptor; if your project enforces offline prepare, run sqlx prepare to refresh.


252-256: Schema-qualify the UDF call to decouple from session search_path.

Mirrors the migration; prevents runtime failures if search_path changes.

-        FROM LATERAL (
-            SELECT jsonb_to_textarr(name) AS name, idx
+        FROM LATERAL (
+            SELECT public.jsonb_to_textarr(name) AS name, idx
             FROM jsonb_array_elements($2) WITH ORDINALITY AS t(name, idx)
         ) in_ns

261-264: Redundant NULL checks on input-derived columns.

in_t.name and in_ns.name cannot be NULL given the sources; consider dropping these predicates for clarity.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6dabd8 and 367c8d5.

📒 Files selected for processing (3)
  • crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: sqlx-check
🔇 Additional comments (5)
crates/lakekeeper/migrations/20250916082614_jsonb_to_textarr.sql (1)

2-4: LGTM on body and volatility.

Ordered aggregation with ordinality is correct; IMMUTABLE + STRICT + PARALLEL SAFE are appropriate.

crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (4)

194-205: Docs match the intended key-casing behavior.

Clear explanation of mapping inputs (including duplicates across casings) to results.


317-321: Filling missing inputs with None is correct.

Ensures 1:1 coverage with the request set; preserves casing in keys.


140-178: Single-ident lookup relies on column collation.

No change needed if namespace_name and t.name are collated CI; otherwise this path remains case-sensitive. Please confirm DDL matches assumptions (see verification script above).


258-260: Verify array-element collation for namespace.namespace_name and matching collation/index for tabular.name

Context: JOIN at crates/lakekeeper/src/implementations/postgres/tabular/mod.rs (lines 258–260). No migrations located in the repo — unable to verify. Run these SQL checks in psql and paste results:

  1. Column types:
    SELECT table_schema, table_name, column_name, data_type, udt_name
    FROM information_schema.columns
    WHERE (table_name='namespace' AND column_name='namespace_name') OR (table_name='tabular' AND column_name='name');

  2. Collation/element type detail:
    SELECT cl.relname AS table, a.attname AS column, t.typname AS col_type, elem.typname AS elem_type, c.collname AS att_collation, ec.collname AS elem_collation
    FROM pg_attribute a
    JOIN pg_class cl ON a.attrelid = cl.oid
    JOIN pg_type t ON a.atttypid = t.oid
    LEFT JOIN pg_type elem ON t.typelem = elem.oid
    LEFT JOIN pg_collation c ON a.attcollation = c.oid
    LEFT JOIN pg_collation ec ON elem.typcollation = ec.oid
    WHERE cl.relname IN ('namespace','tabular') AND a.attname IN ('namespace_name','name') AND a.attnum > 0;

  3. citext extension present?
    SELECT extname FROM pg_extension WHERE extname = 'citext';

  4. Unique constraints on tabular:
    SELECT conname, pg_get_constraintdef(oid) AS def
    FROM pg_constraint
    WHERE conrelid = 'tabular'::regclass AND contype = 'u';

  5. Indexes referencing name/namespace_name:
    SELECT indexname, indexdef FROM pg_indexes WHERE tablename IN ('tabular','namespace') AND (indexdef ILIKE '%name%' OR indexdef ILIKE '%namespace_name%');

Expected check: Postgres compares arrays element-wise. If namespace.namespace_name is text[] with default (case-sensitive) collation, the JOIN will be case-sensitive. Ensure either:

  • namespace.namespace_name elements are citext[] (or text[] with a case-insensitive element collation) AND tabular.name is citext or uses the same collation and matching unique/index definitions; OR
  • normalize comparisons (e.g., lower()) and ensure indexes/uniques align with that normalization.

@mooori
mooori requested a review from c-thiel September 17, 2025 06:46
@mooori

mooori commented Sep 20, 2025

Copy link
Copy Markdown
Contributor Author

@c-thiel this is now on top of the postgres migration.

@c-thiel c-thiel left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration test doesn't seem to work.

EDIT: Seems to be my bad

c-thiel
c-thiel previously approved these changes Sep 21, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure if this warrants a migration.
Migrations are here forever - do you think having it inline would be large disadvantage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is now inlined and the migration removed. The motivation for having a function was readability, though I think after inlining it's still manageable.

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@mooori
mooori requested a review from c-thiel September 22, 2025 10:27
@c-thiel
c-thiel merged commit 602e611 into main Sep 22, 2025
@c-thiel
c-thiel deleted the mz/fix-case-insensitivity branch September 22, 2025 12:29
@c-thiel c-thiel mentioned this pull request Sep 22, 2025
mrjoe7 added a commit to mrjoe7/lakekeeper that referenced this pull request Oct 30, 2025
* feat: Publish images to Dockerhub (lakekeeper#1274)

* feat: Update UI to 0.9.0 with multi-project support (lakekeeper#1275)

* chore: release 0.9.4

Release-As: 0.9.4

* chore: release main (lakekeeper#1262)

* chore(ci): Fix Dockerhub login

* chore(docs): Improve developer guide (lakekeeper#1265)

* chore(docs): add info regarding `view_version`'s internal representation (lakekeeper#1261)

* chore(docs): Architecture clarify Secret Store (lakekeeper#1284)

* fix: Update Limes to 0.2.2 - Fixes compilation issue due to breaking `jwks_client_rs` change (lakekeeper#1282)

* fix: Update Limes to 0.2.2

* increase min rust version

* chore: release 0.9.5

Release-As: 0.9.5

* chore: release main (lakekeeper#1286)

* chore: enable changelog sections for release-please (lakekeeper#1264)

k

* fix(deps): update rust crate rand to v0.9.2 (lakekeeper#1252)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-channel to v2.5.0 (lakekeeper#1225)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency mkdocs-material to v9.6.17 (lakekeeper#1289)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate anyhow to v1.0.99 (lakekeeper#1290)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Remove bitnami images (lakekeeper#1288)

* feat!: Move to Lakekeeper IO based on hyperscaler SDKs (lakekeeper#1285)

* chore(deps): update rust crate reqwest to v0.12.23 (lakekeeper#1294)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(docs): Improve Cloud storage test docs

* fix: accept "disable" as PG sslmode as documented (lakekeeper#1303)

* feat: Simplify task interface, re-exports, enable delete-after-commit (lakekeeper#1302)

* feat: Introduce `RequestMetadata` for Internal Principals which bypass AuthZ (lakekeeper#1306)

* chore(deps): update azure/setup-helm action to v4.3.1 (lakekeeper#1299)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(test): use nextest filterset instead of needs_env_var (lakekeeper#1304)

* chore(deps): update rust crate openssl-src to v300.5.2 (lakekeeper#1292)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-compression to v0.4.28 (lakekeeper#1311)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate thiserror to v2.0.16 (lakekeeper#1296)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Provide `ApiContext` to externally registered tasks (lakekeeper#1307)

* feat!: Simplify Task interface, extend SpecializedTask interface (lakekeeper#1310)

* feat: Improve authorizer `are_allowed_*` batch check signature (lakekeeper#1315)

* chore(authz): Enforce use of AuthZ decisions with #[must_use] (lakekeeper#1317)

* feat: Task Management APIs (lakekeeper#1316)

* chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (lakekeeper#1318)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Add `RunNow` and `RunAt` to Controls for Tasks (lakekeeper#1322)

* chore(deps): update rust crate tokio-util to v0.7.16 (lakekeeper#1313)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(docs): Improve Entra ID docs (lakekeeper#1325)

* chore(docs): Improve Upgrades & Migration docs (lakekeeper#1326)

* feat: Add tasks heartbeat with Catalog state (lakekeeper#1324)

* ci: add configuration for CodeRabbit reviews (lakekeeper#1327)

* feat: Add optional STS session-tags in S3 STS requests for ABAC authorization (lakekeeper#1230)

* feat: Random Server IDs (lakekeeper#1328)

* chore(deps): update rust crate percent-encoding to v2.3.2 (lakekeeper#1312)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(authz): Deprecate Permission Endpoints for Tables without WarehouseIDs (lakekeeper#1334)

* fix: Tasks endpoints in router (lakekeeper#1335)

* feat(ci): add nextest profile ci_no_secrets for external PRs (lakekeeper#1333)

* chore(deps): update rust crate chrono to v0.4.42 (lakekeeper#1331)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Pin examples duckdb version to 1.3 (lakekeeper#1343)

* feat!: Require warehouse_id when checking permissions on views or tables via ID (lakekeeper#1340)

* fix: migrate away from bitnami in unittest.yml (lakekeeper#1344)

* chore: Remove coderabitt config

* fix(docs): Fix inconsistent URL format in README (lakekeeper#1345)

Co-authored-by: Christian <[email protected]>

* feat: Remove serde_yaml & serde_yml (lakekeeper#1341)

* feat!: add `warehouse_id` to PKs of all `table_*` and `view_*` tables (lakekeeper#1254)

* feat: Minor namespace join performance improvements

* fix: Warehouse permissions are directly used for task retrieval & control (lakekeeper#1347)

* fix: Potential Race Condition when undropping Tabulars (lakekeeper#1342)

* fix: table rename authz and error handling (lakekeeper#1346)

Co-authored-by: Andre Luis Anastacio <[email protected]>

* chore(deps): update rust crate google-cloud-auth to v1.1.2 (lakekeeper#1337)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate time to v0.3.44 (lakekeeper#1349)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency mkdocs-material to v9.6.20 (lakekeeper#1309)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* feat: Set ServerID during migration (lakekeeper#1348)

* chore(deps): Remove utoipa fork (lakekeeper#1352)

* chore(deps): update rust crate serde_with to v3.14.1 (lakekeeper#1351)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate url to v2.5.7 (lakekeeper#1354)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-compression to v0.4.30 (lakekeeper#1323)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate serde_json to v1.0.145 (lakekeeper#1250)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update strum monorepo to v0.27.2 (lakekeeper#1251)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update serde monorepo to v1.0.226 (lakekeeper#1355)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update rust crate clap to v4.5.48 (lakekeeper#1356)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Add Entity Names to Tasks (lakekeeper#1353)

* fix: case insensitivity of catalog endpoints (lakekeeper#1338)

* fix: Improve delete_warehouse error message for active tasks

* chore(deps): update rust crate tempfile to v3.22.0 (lakekeeper#1359)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate axum-prometheus to 0.9.0 (lakekeeper#1358)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: PgSslMode not supported error string

* feat(authz)!: add OpenFGA schema v4 and v3->v4 migration (lakekeeper#1314)

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>

* chore(deps): update rust crate uuid to v1.18.1 (lakekeeper#1362)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency markdown-grid-tables to v0.6.0 (lakekeeper#1357)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate anyhow to v1.0.100 (lakekeeper#1350)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: clippy

* chore(deps): update rust crate moka to v0.12.11 (lakekeeper#1365)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate tempfile to v3.23.0 (lakekeeper#1367)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-nats to 0.43.0 (lakekeeper#1366)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-node action to v5 (lakekeeper#1371)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/checkout action to v5 (lakekeeper#1369)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-python action to v6 (lakekeeper#1372)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: V3 support (lakekeeper#1364)

* chore: Set Get Task Permission to "CanGetMetadata" (lakekeeper#1376)

* chore(deps): update dependency node to v22 (lakekeeper#1373)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(authz)!: extend OpenFGA tabular entities with WarehouseId (lakekeeper#1329)


---------

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>

* feat: Add support for tasks affecting views (lakekeeper#1378)

* feat(authz): Add specific Task Actions (lakekeeper#1379)

* chore(tests): Test with Iceberg 1.9.2 & 1.10.0 (lakekeeper#1267)

* feat: Enrich task metadata with concrete tabular type (lakekeeper#1383)

* feat: Add loadTable Snapshots filter (lakekeeper#1385)

* feat: add endpoint for fuzzy search of tabulars (lakekeeper#1387)

* feat: Update UI to 0.10.0 (lakekeeper#1390)

* feat(ui): Update UI to 0.10.1

* chore: Use lakekeeper re-exports in bin (lakekeeper#1391)

* fix(tabular-search): distance and docs for `searchterm is uuid` (lakekeeper#1393)

* chore(examples): Idempotent bucket creation in minimal example (lakekeeper#1386)

In the case where you already have a bucket created, like the "examples" bucket, I ran into an issue where the createbuckets service fails, and this prevents lakekeeper from starting back up.

This fix adds a simple minio flag to ignore buckets that already exist, making things even more user friendly

* feat: Make number of workers spawned for Expiration & Purge configurable (lakekeeper#1395)

* chore: release main (lakekeeper#1295)

* chore: added gif to readme (lakekeeper#1396)

* chore: remove unneded `#[allow(dead_code)]` (lakekeeper#1399)

* fix: Use FnOnce for queue & service registration

* Revert "fix: Use FnOnce for queue & service registration"

This reverts commit 47b03a0.

* chore(docs): Add 0.10 docs

* perf(db): remove `join namespace` from `active_tabulars` view (lakekeeper#1401)

* doc(db): how to connect to db and inspect schema (lakekeeper#1402)

* feat: implement `OpenFgaEntity` for `ServerId` (lakekeeper#1394)

* impl OpenFgaEntity
* Use the implementation

* fix: Use FnOnce for queue & service registration (lakekeeper#1404)

* chore(deps): update dependency mkdocs-material to v9.6.21 (lakekeeper#1406)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Expose client-managed X-Iceberg-Access-Delegation (lakekeeper#1407)

* fix: Use higher consistency for some OpenFGA queries (lakekeeper#1408)

* feat: Improve Kubernetes Auth docs (lakekeeper#1415)

* chore: release 0.10.1

Release-As: 0.10.1

* fix: Endpoint stats for Project Endpoints (lakekeeper#1412)

* feat: Add create table guard to cleanup location on Failure (lakekeeper#1418)

* chore: Generate ID types with Macro (lakekeeper#1419)

* chore: Re-Export Tokio from lakekeeper-io create (lakekeeper#1420)

* fix: Add support for `write.metadata.metrics.` Table Properties (lakekeeper#1422)

* fix: Update UI to 0.10.2 (lakekeeper#1423)

* chore: release main (lakekeeper#1403)

* fix: Parse empty ProjectID headers as None (lakekeeper#1424)

* chore: release 0.10.2

Release-As: 0.10.2

* chore: release main (lakekeeper#1425)

* feat: Add `debug_migrate_before_serve` env var (lakekeeper#1426)

* feat: Move OpenFGA Authorizer to separate crate (lakekeeper#1421)

* chore(renovate): Group dependencies

* chore(renovate): ignore additional deps

* chore: Rename src/service -> src/server, trait Catalog -> CatalogStore (lakekeeper#1428)

* feat(examples): add k8s iceberg sink connector (avro) (lakekeeper#1336)


---------

Co-authored-by: Christian <[email protected]>

* chore(ci): Fix release please (lakekeeper#1433)

* feat: Expose License Information via API (lakekeeper#1432)

* fix(deps): update all non-major dependencies (lakekeeper#1429)

* chore(ci): Remove mgmt API version update via release-please

* chore: Restructure catalog_store into multiple modules (lakekeeper#1434)

* feat: Validate Downscoping works on Warehouse creation (lakekeeper#1437)

* chore(ci): Fix release please

* docs: Add info about installing sqlx to developer-guide.md (lakekeeper#1438)

* docs: Update developer-guide.md (lakekeeper#1439)

* chore(deps): update all non-major dependencies (lakekeeper#1436)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: Better normalization for ARNs in S3 Profile (lakekeeper#1441)

* chore(deps): update all non-major dependencies (lakekeeper#1442)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(main): release 0.10.3 (lakekeeper#1427)

* fix: Release Please CI outputs

* fix(ci): Revert 0.10.3 release

* chore(main): release 0.10.3 (lakekeeper#1446)

* feat: Introduce CatalogWarehouseOps & CatalogNamespaceOps abstractions (lakekeeper#1440)

* feat: Allow x-user-agent header (lakekeeper#1453)

* feat: Table & View Ops Abstractions, Improved Error Handling (lakekeeper#1454)

* fix: CORS allow access delegation & etag headers (lakekeeper#1455)

* fix: Headers should be lowercase (lakekeeper#1457)

* chore(tests): Add trino information_schema.tables test (lakekeeper#1456)

* chore: Introduce open-api feature to gate utoipa and swagger (lakekeeper#1458)

* chore: Release As 0.11

* fix: Debug assertion table identifier mismatch for signer (lakekeeper#1460)

* feat: Caching Short-Term-Credentials (STC) (lakekeeper#1459)

* feat: Warehouse Cache (lakekeeper#1462)

* chore(deps): update actions/setup-node action to v6 (lakekeeper#1443)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Version based Warehouse Cache (lakekeeper#1465)

* feat: AuthZ Server and Project Ops (lakekeeper#1471)

* chore(deps): update github artifact actions (lakekeeper#1461)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Rename release branch pattern to rel-*

* feat: Catalog returns full Namespace Hierarchy for nested Namespaces (lakekeeper#1472)

---------

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>
Co-authored-by: Dao Thanh Tung <[email protected]>
Co-authored-by: Moritz Zielke <[email protected]>
Co-authored-by: Baptiste Gouhoury <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dolan Antenucci <[email protected]>
Co-authored-by: Anatoly Popov <[email protected]>
Co-authored-by: Andre Luis Anastacio <[email protected]>
Co-authored-by: Scott Haines <[email protected]>
Co-authored-by: Viktor Kessler <[email protected]>
Co-authored-by: Yohan Valencia <[email protected]>
Co-authored-by: Paul Roman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure case insensitivity of Catalog endpoints

2 participants