Repository navigation
[SQL] Add a runtime warning about map key deprecation - #8250
Conversation
| if key.is_none() { | ||
| static LOGGED: Once = Once::new(); | ||
| LOGGED.call_once(|| { | ||
| tracing::error!( |
There was a problem hiding this comment.
pitfall (medium): This error fires once per process, and it doesn't say which view or SQL expression produced the NULL key, or how to fix it. In a pipeline with many MAP[...] / MAP(SELECT ...) sites, users can't find the offending query. Two possible fixes: have the compiler pass the source position (or the view name) as a &'static str argument and include it in the message, and add the fix hint that's already in the changelog, e.g. "wrap the key in COALESCE(k, ...) or filter with WHERE k IS NOT NULL".
|
What I ran
Missing (medium), gate "tests for changed behaviour": the compiler now emits --- a/sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/simple/MapTests.java
+++ b/sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/simple/MapTests.java
+ @Test
+ public void nullableMapKeyLiteral() {
+ // NULL map keys are deprecated, but still accepted
+ var ccs = this.getCCS("""
+ CREATE TABLE T(k varchar, x int);
+ CREATE VIEW V AS SELECT p.k IS NULL AS n, p.v
+ FROM T CROSS JOIN UNNEST(MAP[T.k, T.x]) AS p(k, v);""");
+ ccs.stepWeightOne("INSERT INTO T VALUES('a', 1), (NULL, 2)", """
+ n | v
+ -------
+ f | 1
+ t | 2""");
+ }
+
+ @Test
+ public void nullableMapKeySubquery() {
+ var ccs = this.getCCS("""
+ CREATE TABLE T(k varchar, x int);
+ CREATE VIEW V AS SELECT p.k IS NULL AS n, p.v
+ FROM UNNEST(MAP(SELECT k, x FROM T)) AS p(k, v);""");
+ ccs.stepWeightOne("INSERT INTO T VALUES('a', 1), (NULL, 2)", """
+ n | v
+ -------
+ f | 1
+ t | 2""");
+ }Commit message (low, non-blocking): the subject is cut off with Otherwise, the docs and changelog cover the deprecation, and the PR adds no |
… deprecated Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
444bafb to
1d40b06
Compare
Linked Issue
This is a temporary alternative until we can merge #8191
The documentation warns that NULL keys in maps will no longer be supported.
The runtime will log an error the first time a map with a NULL key is constructed.
Note that the type system already prevents such MAP values in tables.