leaves12138 commented on code in PR #8651:
URL: https://github.com/apache/paimon/pull/8651#discussion_r3585266709
##########
paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java:
##########
@@ -957,22 +958,78 @@ private static void
validatePrimaryKeyVectorIndex(TableSchema schema, CoreOption
options.primaryKeyVectorDistanceMetric(indexColumn));
}
+ private static void validatePrimaryKeyFullTextIndex(TableSchema schema,
CoreOptions options) {
+ if (!options.primaryKeyFullTextIndexEnabled()) {
+ return;
+ }
+
+ List<String> indexColumns = options.primaryKeyFullTextIndexColumns();
+ checkArgument(
+ indexColumns.size() == 1,
+ "%s must contain exactly one column in the first release, but
is %s.",
+ CoreOptions.PK_FULL_TEXT_INDEX_COLUMNS.key(),
+ indexColumns);
+ String indexColumn = indexColumns.get(0);
+ checkArgument(
+ !StringUtils.isNullOrWhitespaceOnly(indexColumn),
+ "%s must contain a non-empty column.",
+ CoreOptions.PK_FULL_TEXT_INDEX_COLUMNS.key());
+ checkArgument(
+ !schema.primaryKeys().isEmpty(),
+ "Primary-key full-text index requires a primary-key table.");
+ checkArgument(
+ options.mergeEngine() == MergeEngine.FIRST_ROW ||
options.deletionVectorsEnabled(),
+ "Primary-key full-text index requires deletion-vectors.enabled
= true.");
+ checkArgument(
+ !options.deletionVectorsMergeOnRead(),
+ "Primary-key full-text index requires
deletion-vectors.merge-on-read = false.");
+ checkArgument(
+ options.bucket() > 0 || options.bucket() ==
BucketMode.POSTPONE_BUCKET,
+ "Primary-key full-text index requires fixed or postpone bucket
mode "
+ + "(bucket > 0 or bucket = -2), but bucket is %s.",
+ options.bucket());
+ checkArgument(
+ !options.pkClusteringOverride(),
+ "Primary-key full-text index does not support
pk-clustering-override.");
+ checkArgument(
+ schema.nameToFieldMap().containsKey(indexColumn),
+ "%s entry '%s' must reference an existing column.",
+ CoreOptions.PK_FULL_TEXT_INDEX_COLUMNS.key(),
+ indexColumn);
+ DataTypeRoot typeRoot =
schema.nameToFieldMap().get(indexColumn).type().getTypeRoot();
+ checkArgument(
+ typeRoot == DataTypeRoot.CHAR || typeRoot ==
DataTypeRoot.VARCHAR,
+ "%s entry '%s' must reference a CHAR/VARCHAR/STRING column.",
+ CoreOptions.PK_FULL_TEXT_INDEX_COLUMNS.key(),
+ indexColumn);
+ }
Review Comment:
Could we resolve during schema validation and add tests for malformed JSON
and conflicting global/field-scoped options? Currently passes , but later
fails when initializes the writer. This lets an invalid table definition be
committed and defers the error until write setup.
--
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]