raminqaf commented on code in PR #29760:
URL: https://github.com/apache/flink/pull/29760#discussion_r4467320331


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/formats/raw/RawFormatFactory.java:
##########
@@ -163,6 +177,46 @@ private static void checkFieldType(LogicalType fieldType) {
         }
     }
 
+    /**
+     * Checks the options of a VARIANT column. The binary encoding can hold 
any byte, so it cannot
+     * be split by a line delimiter, and it is not text, so the charset does 
not apply to it.
+     */
+    private static void checkVariantOptions(
+            LogicalType fieldType,
+            String charsetName,
+            VariantEncoding variantEncoding,
+            Optional<String> lineDelimiter) {
+        if (variantEncoding == VariantEncoding.JSON) {
+            checkVariantCharset(fieldType, charsetName);
+        } else if (fieldType.is(LogicalTypeRoot.VARIANT) && 
lineDelimiter.isPresent()) {
+            throw new ValidationException(
+                    String.format(
+                            "The 'raw' format does not support '%s.%s' for a 
VARIANT column "
+                                    + "with '%s.%s' set to '%s'.",
+                            IDENTIFIER,
+                            RawFormatOptions.LINE_DELIMITER.key(),
+                            IDENTIFIER,
+                            RawFormatOptions.VARIANT_ENCODING.key(),
+                            VariantEncoding.BINARY));
+        }
+    }
+
+    /**
+     * Checks that a VARIANT column uses UTF-8, which RFC 8259 requires for 
JSON exchanged between
+     * systems and which {@code PARSE_JSON} reads.
+     */
+    private static void checkVariantCharset(LogicalType fieldType, String 
charsetName) {
+        if (fieldType.is(LogicalTypeRoot.VARIANT)

Review Comment:
   addressed



-- 
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]

Reply via email to