raminqaf commented on code in PR #30092:
URL: https://github.com/apache/flink/pull/30092#discussion_r4693101636
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -3313,6 +3313,16 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
"org.apache.flink.table.runtime.functions.scalar.XmlStringFunction")
.build();
+ public static final BuiltInFunctionDefinition IS_VALID_VARIANT =
+ BuiltInFunctionDefinition.newBuilder()
+ .name("IS_VALID_VARIANT")
+ .kind(SCALAR)
+
.inputTypeStrategy(sequence(logical(LogicalTypeRoot.VARIANT)))
Review Comment:
Done. The argument is now `variant_expr`, declared as
`StaticArgument.scalar("variant_expr", DataTypes.VARIANT(), false)` (adding a
overload would touch a `@PublicEvolving` class).
A static argument fixes the type, so the result is now a nullable `BOOLEAN`.
With nullableIfArgs, SQL returned `BOOLEAN NOT NULL` for a NOT NULL input while
the Table API returned BOOLEAN, so I made it always nullable.
##########
docs/data/functions/variant/is_valid_variant.yml:
##########
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License
+
+name: IS_VALID_VARIANT
+summary: Returns whether a `VARIANT` follows the Parquet Variant encoding.
+
+syntax:
+ sql: IS_VALID_VARIANT(variant)
+ java: $("variant").isValidVariant()
+ python: col("variant").is_valid_variant()
+
+arguments:
+ - name: variant
+ type: VARIANT
+ required: true
+ description: The value to check.
+
+returns:
+ description: TRUE if `variant` follows the Parquet Variant encoding at any
depth. Every part can be read, the fields of each object are sorted by their
keys with no key twice, and every key and string is UTF-8. FALSE otherwise,
such as when its binary encoding is malformed or uses a type that this version
doesn't know.
+ nulls: Returns NULL if `variant` is NULL.
+ type: "`BOOLEAN`, NOT NULL if `variant` is NOT NULL."
+
+notes:
+ - An invalid value comes from bytes that Flink didn't encode, such as a
`VARIANT` that another engine wrote. Use `IS_VALID_VARIANT` to filter such
values before reading or storing them. A value that can't be read makes
`VARIANT_GET` and a cast fail the job, while `TRY_VARIANT_GET` returns NULL. In
an object with 32 or more fields whose keys aren't sorted, a field lookup can
miss a field that exists.
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]