World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#1971] improvement(all): Remove all java doc warning information with JDK17 (#1994)
Qi Yubac67544dd0d
diff --git a/api/src/main/java/com/datastrato/gravitino/Catalog.java b/api/src/main/java/com/datastrato/gravitino/Catalog.javaindex 4a538c8577..77ecdf2948 100644--- a/api/src/main/java/com/datastrato/gravitino/Catalog.java+++ b/api/src/main/java/com/datastrato/gravitino/Catalog.java@@ -17,9 +17,14 @@ public interface Catalog extends Auditable {/** The type of the catalog. */enum Type {- RELATIONAL, // Catalog Type for Relational Data Structure, like db.table, catalog.db.table.- FILE, // Catalog Type for File System (including HDFS, S3, etc.), like path/to/file- STREAM, // Catalog Type for Streaming Data, like kafka://topic+ /** Catalog Type for Relational Data Structure, like db.table, catalog.db.table. */+ RELATIONAL,++ /** Catalog Type for File System (including HDFS, S3, etc.), like path/to/file */+ FILE,++ /** Catalog Type for Message Queue, like kafka://topic */+ STREAM,}/**diff --git a/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java b/api/src/main/java/com/datastrato/gravitino/NameIdentifier.javaindex 68921c4e84..71ce27a1de 100644--- a/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java+++ b/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java@@ -230,6 +230,13 @@ public class NameIdentifier {}}+ /**+ * Check the given condition is true. Throw an {@link IllegalNameIdentifierException} if it's not.+ *+ * @param condition The condition to check.+ * @param message The message to throw.+ * @param args The arguments to the message.+ */public static void check(boolean condition, String message, Object... args) {if (!condition) {throw new IllegalNameIdentifierException(String.format(message, args));diff --git a/api/src/main/java/com/datastrato/gravitino/Namespace.java b/api/src/main/java/com/datastrato/gravitino/Namespace.javaindex eae4946aa0..fbedaa8c17 100644--- a/api/src/main/java/com/datastrato/gravitino/Namespace.java+++ b/api/src/main/java/com/datastrato/gravitino/Namespace.java@@ -220,6 +220,13 @@ public class Namespace {return DOT.join(levels);}+ /**+ * Check the given condition is true. Throw an {@link IllegalNamespaceException} if it's not.+ *+ * @param expression The expression to check.+ * @param message The message to throw.+ * @param args The arguments to the message.+ */public static void check(boolean expression, String message, Object... args) {if (!expression) {throw new IllegalNamespaceException(String.format(message, args));diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.javaindex be7c2e9a58..52d427a443 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when an entity or resource already exists. */public class AlreadyExistsException extends GravitinoRuntimeException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public AlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public AlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.javaindex 5df478e9f1..f40dafabef 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java@@ -6,10 +6,22 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when the request is invalid. */public class BadRequestException extends GravitinoRuntimeException {++ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public BadRequestException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public BadRequestException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.javaindex ce792f1441..c2642981e0 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a resource already exists. */public class CatalogAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public CatalogAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public CatalogAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.javaindex 83f44f7d47..ae350a2832 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a file with specified name already exists. */public class FilesetAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public FilesetAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public FilesetAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.javaindex 1c56b24f4b..2306e75f83 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Base class for all Gravitino runtime exceptions. */public class GravitinoRuntimeException extends RuntimeException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public GravitinoRuntimeException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public GravitinoRuntimeException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.javaindex 17d9ae775b..cec746c5d5 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java@@ -7,18 +7,35 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a name identifier is invalid. */public class IllegalNameIdentifierException extends IllegalArgumentException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public IllegalNameIdentifierException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public IllegalNameIdentifierException(String message, Throwable cause) {super(message, cause);}+ /**+ * Constructs a new exception with the specified cause.+ *+ * @param cause the cause.+ */public IllegalNameIdentifierException(Throwable cause) {super(cause);}+ /** Constructs a new exception with the specified detail message and cause. */public IllegalNameIdentifierException() {super();}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.javaindex 3de54c6690..ed38976789 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java@@ -7,18 +7,35 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a namespace is invalid. */public class IllegalNamespaceException extends IllegalArgumentException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public IllegalNamespaceException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public IllegalNamespaceException(String message, Throwable cause) {super(message, cause);}+ /**+ * Constructs a new exception with the specified cause.+ *+ * @param cause the cause.+ */public IllegalNamespaceException(Throwable cause) {super(cause);}+ /** Constructs a new exception with the specified detail message and cause. */public IllegalNamespaceException() {super();}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.javaindex f6e4976c09..d0c464bb4e 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when the metalake already exists. */public class MetalakeAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public MetalakeAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public MetalakeAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.javaindex ee9b97fdeb..19c684b31f 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a catalog is not found. */public class NoSuchCatalogException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchCatalogException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchCatalogException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.javaindex 8cbfd35dc4..f2a645de92 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a column with specified name is not existed. */public class NoSuchColumnException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchColumnException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchColumnException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.javaindex fb24897f96..6d05d0c9e9 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a file with specified name is not existed. */public class NoSuchFilesetException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchFilesetException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchFilesetException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.javaindex 1e2c25d7f5..351a0b69ea 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a metalake is not found. */public class NoSuchMetalakeException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchMetalakeException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchMetalakeException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.javaindex 8fc2c10444..c108268ed2 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a partition with specified name is not existed. */public class NoSuchPartitionException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchPartitionException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchPartitionException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.javaindex 15ef79ccb5..cc79172672 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a schema is not found. */public class NoSuchSchemaException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchSchemaException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchSchemaException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.javaindex ba3fccb313..0ae7c838bd 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a table with specified name is not existed. */public class NoSuchTableException extends NotFoundException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NoSuchTableException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NoSuchTableException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.javaindex 74b5cf72e1..c63a202c8d 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java@@ -8,10 +8,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when a resource is not empty. */public class NonEmptyEntityException extends GravitinoRuntimeException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NonEmptyEntityException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NonEmptyEntityException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.javaindex 906aebb447..59d708d7f2 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a namespace is not empty. */public class NonEmptySchemaException extends GravitinoRuntimeException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public NonEmptySchemaException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public NonEmptySchemaException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.javaindex b7b1e2f8fa..2a98e55371 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Base class for all exceptions thrown when a resource is not found. */public class NotFoundException extends GravitinoRuntimeException {+ /**+ * Constructs a new NotFoundException.+ *+ * @param message The detail message.+ */public NotFoundException(String message) {super(message);}+ /**+ * Constructs a new NotFoundException.+ *+ * @param message The detail message.+ * @param cause The cause of the exception.+ */public NotFoundException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.javaindex 1268fde74d..2050796596 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a partition with specified name already exists. */public class PartitionAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public PartitionAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public PartitionAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.javaindex 319b29c9c9..e30c6e22f8 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java@@ -25,11 +25,25 @@ import com.google.errorprone.annotations.FormatMethod;/** An exception thrown when a REST request fails. */public class RESTException extends RuntimeException {++ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ * @param args the arguments to the message.+ */@FormatMethodpublic RESTException(String message, Object... args) {super(String.format(message, args));}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param cause the cause.+ * @param message the detail message.+ * @param args the arguments to the message.+ */@FormatMethodpublic RESTException(Throwable cause, String message, Object... args) {super(String.format(message, args), cause);diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.javaindex a26859937b..0552c41261 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** An exception thrown when the schema already exists. */public class SchemaAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new SchemaAlreadyExistsException.+ *+ * @param message the detail message.+ */public SchemaAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new SchemaAlreadyExistsException.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public SchemaAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.javaindex 4e28a6d374..d2071629d4 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java@@ -7,10 +7,21 @@ package com.datastrato.gravitino.exceptions;/** Exception thrown when a table with specified name already exists. */public class TableAlreadyExistsException extends AlreadyExistsException {+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public TableAlreadyExistsException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public TableAlreadyExistsException(String message, Throwable cause) {super(message, cause);}diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.javaindex 47dc4b0312..d59ee33041 100644--- a/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java@@ -11,21 +11,44 @@ import java.util.List;/** Exception thrown when a user is not authorized to perform an action. */public class UnauthorizedException extends GravitinoRuntimeException {+ /** The challenges of the exception. */private final List<String> challenges = Lists.newArrayList();+ /**+ * Constructs a new exception with the specified detail message.+ *+ * @param message the detail message.+ */public UnauthorizedException(String message) {super(message);}+ /**+ * Constructs a new exception with the specified detail message and cause.+ *+ * @param message the detail message.+ * @param cause the cause.+ */public UnauthorizedException(String message, Throwable cause) {super(message, cause);}+ /**+ * Constructs a new exception with the specified detail message and challenge.+ *+ * @param message the detail message.+ * @param challenge the challenge.+ */public UnauthorizedException(String message, String challenge) {super(message);challenges.add(challenge);}+ /**+ * Get the challenge of the exception.+ *+ * @return the challenge.+ */public List<String> getChallenges() {return challenges;}diff --git a/api/src/main/java/com/datastrato/gravitino/file/Fileset.java b/api/src/main/java/com/datastrato/gravitino/file/Fileset.javaindex 64a8f4d1da..2f8989a5cc 100644--- a/api/src/main/java/com/datastrato/gravitino/file/Fileset.java+++ b/api/src/main/java/com/datastrato/gravitino/file/Fileset.java@@ -25,10 +25,18 @@ public interface Fileset extends Auditable {/** An enum representing the type of the fileset object. */enum Type {- MANAGED, // Fileset is managed by Gravitino. When specified, the data will be deleted when the- // fileset object is deleted.- EXTERNAL // Fileset is not managed by Gravitino. When specified, the data will not be deleted- // when the fileset object is deleted.++ /**+ * Fileset is managed by Gravitino. When specified, the data will be deleted when the fileset+ * object is deleted+ */+ MANAGED,++ /**+ * Fileset is not managed by Gravitino. When specified, the data will not be deleted when the+ * fileset object is deleted+ */+ EXTERNAL}/** @return Name of the fileset object. */diff --git a/api/src/main/java/com/datastrato/gravitino/rel/Column.java b/api/src/main/java/com/datastrato/gravitino/rel/Column.javaindex 262def6db4..7f7d2555e8 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/Column.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/Column.java@@ -120,6 +120,7 @@ public interface Column {defaultValue == null ? DEFAULT_VALUE_NOT_SET : defaultValue);}+ /** The implementation of {@link Column} for users to use API. */class ColumnImpl implements Column {private String name;private Type dataType;diff --git a/api/src/main/java/com/datastrato/gravitino/rel/SchemaChange.java b/api/src/main/java/com/datastrato/gravitino/rel/SchemaChange.javaindex 1134a1d191..c3a4ad3319 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/SchemaChange.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/SchemaChange.java@@ -46,6 +46,7 @@ public interface SchemaChange {return new RemoveProperty(property);}+ /** SchemaChange class to set the property and value pairs for the schema. */final class SetProperty implements SchemaChange {private final String property;private final String value;@@ -111,6 +112,7 @@ public interface SchemaChange {}}+ /** SchemaChange class to remove a property from the schema. */final class RemoveProperty implements SchemaChange {private final String property;diff --git a/api/src/main/java/com/datastrato/gravitino/rel/SupportsPartitions.java b/api/src/main/java/com/datastrato/gravitino/rel/SupportsPartitions.javaindex 1a632d9d6b..b371f35ab1 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/SupportsPartitions.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/SupportsPartitions.java@@ -8,6 +8,7 @@ import com.datastrato.gravitino.exceptions.NoSuchPartitionException;import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;import com.datastrato.gravitino.rel.partitions.Partition;+/** Interface for tables that support partitions. */public interface SupportsPartitions {/**diff --git a/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java b/api/src/main/java/com/datastrato/gravitino/rel/TableChange.javaindex e60a989e44..cdd68468fa 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/TableChange.java@@ -403,6 +403,12 @@ public interface TableChange {private final String property;private final String value;+ /**+ * Creates a new SetProperty instance.+ *+ * @param property The name of the property to be set.+ * @param value The new value of the property.+ */public SetProperty(String property, String value) {this.property = property;this.value = value;@@ -529,14 +535,22 @@ public interface TableChange {*/interface ColumnPosition {+ /** @return The first position of ColumnPosition instance. */static ColumnPosition first() {return First.INSTANCE;}+ /**+ * Returns the position after the given column.+ *+ * @param column The name of the reference column to place the new column after.+ * @return The position after the given column.+ */static ColumnPosition after(String column) {return new After(column);}+ /** @return The default position of ColumnPosition instance. */static ColumnPosition defaultPos() {return Default.INSTANCE;}@@ -630,6 +644,12 @@ public interface TableChange {* The interface for all column changes. Column changes are used to modify the schema of a table.*/interface ColumnChange extends TableChange {++ /**+ * Retrieves the field name of the column to be modified.+ *+ * @return An array of strings representing the field name.+ */String[] fieldName();}@@ -1103,11 +1123,21 @@ public interface TableChange {this.nullable = nullable;}+ /**+ * Retrieves the field name of the column whose nullability is being updated.+ *+ * @return An array of strings representing the field name.+ */@Overridepublic String[] fieldName() {return fieldName;}+ /**+ * The nullable flag of the column.+ *+ * @return true if the column is nullable; false otherwise.+ */public boolean nullable() {return nullable;}diff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/Expression.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/Expression.javaindex d6028548a2..a252ed7d96 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/Expression.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/Expression.java@@ -25,6 +25,11 @@ import java.util.Set;/** Base class of the public logical expression API. */public interface Expression {++ /**+ * `EMPTY_EXPRESSION` is only used as an input when the default `children` method builds the+ * result.+ */Expression[] EMPTY_EXPRESSION = new Expression[0];/**diff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Distributions.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Distributions.javaindex c701dbb83c..194c58539e 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Distributions.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Distributions.java@@ -11,15 +11,17 @@ import java.util.Arrays;/** Helper methods to create distributions to pass into Gravitino. */public class Distributions {- // NONE is used to indicate that there is no distribution.+ /** NONE is used to indicate that there is no distribution. */public static final Distribution NONE =new DistributionImpl(Strategy.NONE, 0, Expression.EMPTY_EXPRESSION);- // List bucketing strategy hash, TODO: #1505 Separate the bucket number from the Distribution.+ /** List bucketing strategy hash, TODO: #1505 Separate the bucket number from the Distribution. */public static final Distribution HASH =new DistributionImpl(Strategy.HASH, 0, Expression.EMPTY_EXPRESSION);- // List bucketing strategy range, TODO: #1505 Separate the bucket number from the Distribution.+ /**+ * List bucketing strategy range, TODO: #1505 Separate the bucket number from the Distribution.+ */public static final Distribution RANGE =new DistributionImpl(Strategy.RANGE, 0, Expression.EMPTY_EXPRESSION);@@ -101,16 +103,31 @@ public class Distributions {this.expressions = expressions;}+ /**+ * Get the strategy of the distribution.+ *+ * @return The strategy of the distribution.+ */@Overridepublic Strategy strategy() {return strategy;}+ /**+ * Get the number of buckets of the distribution.+ *+ * @return The number of buckets of the distribution.+ */@Overridepublic int number() {return number;}+ /**+ * Get the expressions of the distribution.+ *+ * @return The expressions of the distribution.+ */@Overridepublic Expression[] expressions() {return expressions;@@ -122,21 +139,44 @@ public class Distributions {private int number;private Expression[] expressions;+ /**+ * Set the strategy of the distribution.+ *+ * @param strategy The strategy of the distribution.+ * @return The builder.+ */public Builder withStrategy(Strategy strategy) {this.strategy = strategy;return this;}+ /**+ * Set the number of buckets of the distribution.+ *+ * @param number The number of buckets of the distribution.+ * @return The builder.+ */public Builder withNumber(int number) {this.number = number;return this;}+ /**+ * Set the expressions of the distribution.+ *+ * @param expressions The expressions of the distribution.+ * @return The builder.+ */public Builder withExpressions(Expression[] expressions) {this.expressions = expressions;return this;}+ /**+ * Build the distribution.+ *+ * @return The created distribution.+ */public Distribution build() {return new DistributionImpl(strategy, number, expressions);}diff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Strategy.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Strategy.javaindex 73dff0ffbb..8cdaec9cd9 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Strategy.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/distributions/Strategy.java@@ -23,10 +23,25 @@ public enum Strategy {* of the underlying system.*/NONE,++ /** Uses the hash value of the expression to distribute data. */HASH,++ /**+ * Uses the range of the expression specified to distribute data. The range is specified using the+ * rangeStart and rangeEnd properties.+ */RANGE,++ /** Distributes data evenly across partitions. */EVEN;+ /**+ * Get the distribution strategy by name.+ *+ * @param name The name of the distribution strategy.+ * @return The distribution strategy.+ */public static Strategy getByName(String name) {for (Strategy strategy : Strategy.values()) {if (strategy.name().equalsIgnoreCase(name)) {diff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/NullOrdering.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/NullOrdering.javaindex 893ff168c1..6babf34be5 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/NullOrdering.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/NullOrdering.java@@ -21,7 +21,12 @@ package com.datastrato.gravitino.rel.expressions.sorts;/** A null order used in sorting expressions. */public enum NullOrdering {+ /**+ * Nulls appear before non-nulls. For ascending order, this means nulls appear at the beginning,+ */NULLS_FIRST,++ /** Nulls appear after non-nulls. For ascending order, this means nulls appear at the end. */NULLS_LAST;@Overridediff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/SortDirection.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/SortDirection.javaindex be6063317e..9df1e070e5 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/SortDirection.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/sorts/SortDirection.java@@ -29,7 +29,16 @@ import static com.datastrato.gravitino.rel.expressions.sorts.NullOrdering.NULLS_* explicitly.*/public enum SortDirection {+ /**+ * Ascending sort direction. Nulls appear first. For ascending order, this means nulls appear at+ * the beginning.+ */ASCENDING(NULLS_FIRST),++ /**+ * Descending sort direction. Nulls appear last. For ascending order, this means nulls appear at+ * the end.+ */DESCENDING(NULLS_LAST);private final NullOrdering defaultNullOrdering;@@ -59,6 +68,12 @@ public enum SortDirection {}}+ /**+ * Returns the SortDirection from the string representation.+ *+ * @param str The string representation of the sort direction.+ * @return The SortDirection.+ */public static SortDirection fromString(String str) {switch (str.toLowerCase()) {case "asc":diff --git a/api/src/main/java/com/datastrato/gravitino/rel/expressions/transforms/Transforms.java b/api/src/main/java/com/datastrato/gravitino/rel/expressions/transforms/Transforms.javaindex 66d3fff256..9bdf7aedbd 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/expressions/transforms/Transforms.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/expressions/transforms/Transforms.java@@ -14,15 +14,36 @@ import java.util.Objects;/** Helper methods to create logical transforms to pass into Gravitino. */public class Transforms {+ /** An empty array of transforms. */public static final Transform[] EMPTY_TRANSFORM = new Transform[0];+ /** The name of the identity transform. */public static final String NAME_OF_IDENTITY = "identity";+ /** The name of the year transform. The year transform returns the year of the input value. */public static final String NAME_OF_YEAR = "year";++ /** The name of the month transform. The month transform returns the month of the input value. */public static final String NAME_OF_MONTH = "month";++ /** The name of the day transform. The day transform returns the day of the input value. */public static final String NAME_OF_DAY = "day";++ /** The name of the hour transform. The hour transform returns the hour of the input value. */public static final String NAME_OF_HOUR = "hour";++ /**+ * The name of the bucket transform. The bucket transform returns the bucket of the input value.+ */public static final String NAME_OF_BUCKET = "bucket";++ /**+ * The name of the truncate transform. The truncate transform returns the truncated value of the+ */public static final String NAME_OF_TRUNCATE = "truncate";++ /** The name of the list transform. The list transform includes multiple fields in a list. */public static final String NAME_OF_LIST = "list";++ /** The name of the range transform. The range transform returns the range of the input value. */public static final String NAME_OF_RANGE = "range";/**@@ -192,22 +213,52 @@ public class Transforms {return new ApplyTransform(name, arguments);}+ /**+ * Create an identity transform that applies a function to the input value.+ *+ * @param ref The reference to transform.+ * @return An identity transform.+ */private static IdentityTransform identity(NamedReference ref) {return new IdentityTransform(ref);}+ /**+ * Create a year transform that applies a function to the input value.+ *+ * @param ref The reference to transform.+ * @return A year transform.+ */private static YearTransform year(NamedReference ref) {return new YearTransform(ref);}+ /**+ * Create a month transform that applies a function to the input value.+ *+ * @param ref The reference to transform.+ * @return A month transform.+ */private static MonthTransform month(NamedReference ref) {return new MonthTransform(ref);}+ /**+ * Create a day transform that applies a function to the input value.+ *+ * @param ref The reference to transform.+ * @return A day transform.+ */private static DayTransform day(NamedReference ref) {return new DayTransform(ref);}+ /**+ * Create a hour transform that applies a function to the input value.+ *+ * @param ref The reference to transform.+ * @return A hour transform.+ */private static HourTransform hour(NamedReference ref) {return new HourTransform(ref);}@@ -218,6 +269,7 @@ public class Transforms {this.ref = ref;}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_IDENTITY;@@ -240,6 +292,7 @@ public class Transforms {this.ref = ref;}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_YEAR;@@ -262,6 +315,7 @@ public class Transforms {this.ref = ref;}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_MONTH;@@ -284,6 +338,7 @@ public class Transforms {this.ref = ref;}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_DAY;@@ -306,6 +361,7 @@ public class Transforms {this.ref = ref;}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_HOUR;@@ -333,19 +389,23 @@ public class Transforms {this.fields = fields;}+ /** @return The number of buckets to use. */public int numBuckets() {return numBuckets.value();}+ /** @return The field names to transform. */public String[][] fieldNames() {return Arrays.stream(fields).map(NamedReference::fieldName).toArray(String[][]::new);}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_BUCKET;}+ /** @return The arguments to the transform. */@Overridepublic Expression[] arguments() {return ObjectArrays.concat(numBuckets, fields);@@ -382,19 +442,23 @@ public class Transforms {this.field = field;}+ /** @return The width to truncate to. */public int width() {return width.value();}+ /** @return The field name to transform. */public String[] fieldName() {return field.fieldName();}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_TRUNCATE;}+ /** @return The arguments to the transform. */@Overridepublic Expression[] arguments() {return new Expression[] {width, field};@@ -427,20 +491,24 @@ public class Transforms {this.fields = fields;}+ /** @return The field names to include in the list. */public String[][] fieldNames() {return Arrays.stream(fields).map(NamedReference::fieldName).toArray(String[][]::new);}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_LIST;}+ /** @return The arguments to the transform. */@Overridepublic Expression[] arguments() {return fields;}+ /** @return The assignments to the transform. */@Overridepublic Expression[] assignments() {// todo: resolve this@@ -474,20 +542,24 @@ public class Transforms {this.field = field;}+ /** @return The field name to transform. */public String[] fieldName() {return field.fieldName();}+ /** @return The name of the transform. */@Overridepublic String name() {return NAME_OF_RANGE;}+ /** @return The arguments to the transform. */@Overridepublic Expression[] arguments() {return new Expression[] {field};}+ /** @return The assignments to the transform. */@Overridepublic Expression[] assignments() {// todo: resolve this@@ -519,11 +591,13 @@ public class Transforms {this.arguments = arguments;}+ /** @return The name of the function to apply. */@Overridepublic String name() {return name;}+ /** @return The arguments to the function. */@Overridepublic Expression[] arguments() {return arguments;diff --git a/api/src/main/java/com/datastrato/gravitino/rel/indexes/Index.java b/api/src/main/java/com/datastrato/gravitino/rel/indexes/Index.javaindex 978158ee4e..9a300d12b9 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/indexes/Index.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/indexes/Index.java@@ -23,6 +23,10 @@ public interface Index {*/String[][] fieldNames();+ /**+ * The enum IndexType defines the type of the index. Currently, PRIMARY_KEY and UNIQUE_KEY are+ * supported.+ */enum IndexType {/*** PRIMARY KEY index in a relational database is a field or a combination of fields thatdiff --git a/api/src/main/java/com/datastrato/gravitino/rel/indexes/Indexes.java b/api/src/main/java/com/datastrato/gravitino/rel/indexes/Indexes.javaindex b116437854..4c5385427a 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/indexes/Indexes.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/indexes/Indexes.java@@ -7,6 +7,7 @@ package com.datastrato.gravitino.rel.indexes;/** Helper methods to create index to pass into Gravitino. */public class Indexes {+ /** An empty array of indexes. */public static final Index[] EMPTY_INDEXES = new Index[0];/** MySQL does not support setting the name of the primary key, so the default name is used. */@@ -58,57 +59,98 @@ public class Indexes {.build();}+ /** The user side implementation of the index. */public static final class IndexImpl implements Index {private final IndexType indexType;private final String name;private final String[][] fieldNames;+ /**+ * The constructor of the index.+ *+ * @param indexType The type of the index+ * @param name The name of the index+ * @param fieldNames The field names under the table contained in the index.+ */public IndexImpl(IndexType indexType, String name, String[][] fieldNames) {this.indexType = indexType;this.name = name;this.fieldNames = fieldNames;}+ /** @return The type of the index */@Overridepublic IndexType type() {return indexType;}+ /** @return The name of the index */@Overridepublic String name() {return name;}+ /** @return The field names under the table contained in the index */@Overridepublic String[][] fieldNames() {return fieldNames;}+ /** @return the builder for creating a new instance of IndexImpl. */public static Builder builder() {return new Builder();}/** Builder to create a index. */public static class Builder {++ /** The type of the index. */protected IndexType indexType;++ /** The name of the index. */protected String name;++ /** The field names of the index. */protected String[][] fieldNames;+ /**+ * Set the type of the index.+ *+ * @param indexType The type of the index+ * @return The builder for creating a new instance of IndexImpl.+ */public Indexes.IndexImpl.Builder withIndexType(IndexType indexType) {this.indexType = indexType;return this;}+ /**+ * Set the name of the index.+ *+ * @param name The name of the index+ * @return The builder for creating a new instance of IndexImpl.+ */public Indexes.IndexImpl.Builder withName(String name) {this.name = name;return this;}+ /**+ * Set the field names of the index.+ *+ * @param fieldNames The field names of the index+ * @return The builder for creating a new instance of IndexImpl.+ */public Indexes.IndexImpl.Builder withFieldNames(String[][] fieldNames) {this.fieldNames = fieldNames;return this;}+ /**+ * Build a new instance of IndexImpl.+ *+ * @return The new instance.+ */public Index build() {return new IndexImpl(indexType, name, fieldNames);}diff --git a/api/src/main/java/com/datastrato/gravitino/rel/types/Type.java b/api/src/main/java/com/datastrato/gravitino/rel/types/Type.javaindex d8af929f69..0be8ecf83c 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/types/Type.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/types/Type.java@@ -14,29 +14,65 @@ public interface Type {/** The root type name of this type. */enum Name {+ /** The boolean type. */BOOLEAN,+ /** The byte type. */BYTE,+ /** The short type. */SHORT,+ /** The integer type. */INTEGER,+ /** The long type. */LONG,+ /** The float type. */FLOAT,+ /** The double type. */DOUBLE,+ /** The decimal type. */DECIMAL,+ /** The date type. */DATE,+ /** The time type. */TIME,+ /** The timestamp type. */TIMESTAMP,+ /** The interval year type. */INTERVAL_YEAR,+ /** The interval month type. */INTERVAL_DAY,+ /** The interval day type. */STRING,+ /** The varchar type. */VARCHAR,+ /** The char type with fixed length */FIXEDCHAR,+ /** The UUID type. */UUID,+ /** The binary type with fixed length */FIXED,+ /** The binary type with variable length. The length is specified in the type itself. */BINARY,+ /**+ * The struct type. A struct type is a complex type that contains a set of named fields, each+ * with a type, and optionally a comment.+ */STRUCT,++ /**+ * The list type. A list type is a complex type that contains a set of elements, each with the+ * same type.+ */LIST,++ /**+ * The map type. A map type is a complex type that contains a set of key-value pairs, each with+ * a key type and a value type.+ */MAP,+ /** The union type. A union type is a complex type that contains a set of types. */UNION,++ /** The null type. A null type represents a value that is null. */NULL}diff --git a/api/src/main/java/com/datastrato/gravitino/rel/types/Types.java b/api/src/main/java/com/datastrato/gravitino/rel/types/Types.javaindex f4687e5a2b..7acd718f3f 100644--- a/api/src/main/java/com/datastrato/gravitino/rel/types/Types.java+++ b/api/src/main/java/com/datastrato/gravitino/rel/types/Types.java@@ -208,7 +208,7 @@ public class Types {this.scale = scale;}- public static void checkPrecisionScale(int precision, int scale) {+ static void checkPrecisionScale(int precision, int scale) {Preconditions.checkArgument(precision <= 38,"Decimals with precision larger than 38 are not supported: %s",@@ -217,15 +217,18 @@ public class Types {scale <= precision, "Scale cannot be larger than precision: %s > %s", scale, precision);}+ /** @return The name of the decimal type. */@Overridepublic Name name() {return Name.DECIMAL;}+ /** @return The precision of the decimal type. */public int precision() {return precision;}+ /** @return The scale of the decimal type. */public int scale() {return scale;}@@ -264,6 +267,7 @@ public class Types {private DateType() {}+ /** @return The name of the date type. */@Overridepublic Name name() {return Name.DATE;@@ -318,6 +322,7 @@ public class Types {this.withTimeZone = withTimeZone;}+ /** @return True if the timestamp type has time zone, false otherwise. */public boolean hasTimeZone() {return withTimeZone;}@@ -327,6 +332,7 @@ public class Types {return Name.TIMESTAMP;}+ /** @return The simple string representation of the timestamp type. */@Overridepublic String simpleString() {return withTimeZone ? "timestamp_tz" : "timestamp";@@ -449,6 +455,7 @@ public class Types {return Name.FIXED;}+ /** @return The length of the fixed type. */public int length() {return length;}@@ -498,6 +505,7 @@ public class Types {return Name.VARCHAR;}+ /** @return The length of the var char type. */public int length() {return length;}@@ -547,6 +555,7 @@ public class Types {return Name.FIXEDCHAR;}+ /** @return The length of the fixed char type. */public int length() {return length;}@@ -618,6 +627,7 @@ public class Types {this.fields = fields;}+ /** @return The fields of the struct type. */public Field[] fields() {return fields;}@@ -756,6 +766,7 @@ public class Types {return Objects.hash(name, type, nullable);}+ /** @return The simple string representation of the field. */public String simpleString() {return String.format("%s: %s %s COMMENT %s",@@ -770,14 +781,34 @@ public class Types {/** A list type. Note, this type is not supported in the current version of Gravitino. */public static class ListType extends Type.ComplexType {+ /**+ * Create a new {@link ListType} with the given element type and the type is nullable.+ *+ * @param elementType The element type of the list.+ * @return A new {@link ListType} instance.+ */public static ListType nullable(Type elementType) {return of(elementType, true);}+ /**+ * Create a new {@link ListType} with the given element type.+ *+ * @param elementType The element type of the list.+ * @return A new {@link ListType} instance.+ */public static ListType notNull(Type elementType) {return of(elementType, false);}+ /**+ * Create a new {@link ListType} with the given element type and whether the element is+ * nullable.+ *+ * @param elementType The element type of the list.+ * @param elementNullable Whether the element of the list is nullable.+ * @return A new {@link ListType} instance.+ */public static ListType of(Type elementType, boolean elementNullable) {return new ListType(elementType, elementNullable);}@@ -791,10 +822,12 @@ public class Types {this.elementNullable = elementNullable;}+ /** @return The element type of the list. */public Type elementType() {return elementType;}+ /** @return Whether the element of the list is nullable. */public boolean elementNullable() {return elementNullable;}@@ -836,14 +869,38 @@ public class Types {*/public static class MapType extends Type.ComplexType {+ /**+ * Create a new {@link MapType} with the given key type, value type and the value is nullable.+ *+ * @param keyType The key type of the map.+ * @param valueType The value type of the map.+ * @return A new {@link MapType} instance.+ */public static MapType valueNullable(Type keyType, Type valueType) {return of(keyType, valueType, true);}+ /**+ * Create a new {@link MapType} with the given key type, value type and the value is not+ * nullable.+ *+ * @param keyType The key type of the map.+ * @param valueType The value type of the map.+ * @return A new {@link MapType} instance.+ */public static MapType valueNotNull(Type keyType, Type valueType) {return of(keyType, valueType, false);}+ /**+ * Create a new {@link MapType} with the given key type, value type and whether the value is+ * nullable+ *+ * @param keyType The key type of the map.+ * @param valueType The value type of the map.+ * @param valueNullable Whether the value of the map is nullable.+ * @return A new {@link MapType} instance.+ */public static MapType of(Type keyType, Type valueType, boolean valueNullable) {return new MapType(keyType, valueType, valueNullable);}@@ -863,14 +920,17 @@ public class Types {return Name.MAP;}+ /** @return The key type of the map. */public Type keyType() {return keyType;}+ /** @return The value type of the map. */public Type valueType() {return valueType;}+ /** @return Whether the value of the map is nullable. */public boolean valueNullable() {return valueNullable;}@@ -906,6 +966,12 @@ public class Types {*/public static class UnionType extends Type.ComplexType {+ /**+ * Create a new {@link UnionType} with the given types.+ *+ * @param types The types of the union.+ * @return A new {@link UnionType} instance.+ */public static UnionType of(Type... types) {return new UnionType(types);}@@ -916,6 +982,7 @@ public class Types {this.types = types;}+ /** @return The types of the union. */public Type[] types() {return types;}diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/DefaultOAuth2TokenProvider.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/DefaultOAuth2TokenProvider.javaindex ec2c725160..1bb8592a92 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/DefaultOAuth2TokenProvider.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/DefaultOAuth2TokenProvider.java@@ -46,7 +46,7 @@ public class DefaultOAuth2TokenProvider extends OAuth2TokenProvider {return new Builder();}- /* Builder class for configuring and creating instances of DefaultOAuth2TokenProvider. */+ /** Builder class for configuring and creating instances of DefaultOAuth2TokenProvider. */public static class Builderextends OAuth2TokenProviderBuilder<Builder, DefaultOAuth2TokenProvider> {diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.javaindex d1c694ac0e..70e82584d5 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java@@ -47,6 +47,11 @@ public class ErrorHandlers {return MetalakeErrorHandler.INSTANCE;}+ /**+ * Creates an error handler specific to Catalog operations.+ *+ * @return A Consumer representing the Catalog error handler.+ */public static Consumer<ErrorResponse> catalogErrorHandler() {return CatalogErrorHandler.INSTANCE;}@@ -87,6 +92,11 @@ public class ErrorHandlers {return RestErrorHandler.INSTANCE;}+ /**+ * Creates an error handler specific to OAuth2 requests.+ *+ * @return A Consumer representing the OAuth2 error handler.+ */public static Consumer<ErrorResponse> oauthErrorHandler() {return OAuthErrorHandler.INSTANCE;}@@ -293,9 +303,18 @@ public class ErrorHandlers {}}+ /** * Error handler specific to OAuth2 requests. */public static class OAuthErrorHandler extends RestErrorHandler {private static final ErrorHandler INSTANCE = new OAuthErrorHandler();+ /**+ * Parses the error response from the server.+ *+ * @param code The response code indicating the error status.+ * @param json The JSON data representing the error response.+ * @param mapper The ObjectMapper used to deserialize the JSON data.+ * @return An ErrorResponse object representing the error response.+ */@Overridepublic ErrorResponse parseResponse(int code, String json, ObjectMapper mapper) {try {@@ -308,6 +327,11 @@ public class ErrorHandlers {return ErrorResponse.unknownError(errorMsg);}+ /**+ * Accepts the error response and throws an exception based on the error type.+ *+ * @param errorResponse the input argument+ */@Overridepublic void accept(ErrorResponse errorResponse) {if (errorResponse.getType() != null) {diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.javaindex f9e55c6cfd..84ad1d8ff5 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java@@ -192,6 +192,11 @@ public class GravitinoClient implements SupportsMetalakes, Closeable {}}+ /**+ * Retrieves the version of the Gravitino API.+ *+ * @return A GravitinoVersion instance representing the version of the Gravitino API.+ */public GravitinoVersion getVersion() {VersionResponse resp =restClient.get(diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoVersion.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoVersion.javaindex c1b126b118..837ef347a0 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoVersion.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoVersion.java@@ -6,6 +6,7 @@ package com.datastrato.gravitino.client;import com.datastrato.gravitino.dto.VersionDTO;+/** Gravitino version information. */public class GravitinoVersion extends VersionDTO {GravitinoVersion(VersionDTO versionDTO) {super(versionDTO.version(), versionDTO.compileDate(), versionDTO.gitCommit());diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/KerberosTokenProvider.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/KerberosTokenProvider.javaindex 7a8ab7d89f..d9723f0bdb 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/KerberosTokenProvider.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/KerberosTokenProvider.java@@ -147,6 +147,7 @@ public final class KerberosTokenProvider implements AuthDataProvider {return new Builder();}+ /** Builder class for configuring and creating instances of KerberosTokenProvider. */public static class Builder {private String clientPrincipal;private File keyTabFile;diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/OAuth2TokenProvider.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/OAuth2TokenProvider.javaindex 9513490adf..540970dce8 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/OAuth2TokenProvider.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/OAuth2TokenProvider.java@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;*/public abstract class OAuth2TokenProvider implements AuthDataProvider {+ /** The HTTP client used to request the access token from the authorization server. */protected HTTPClient client;/**@@ -55,6 +56,11 @@ public abstract class OAuth2TokenProvider implements AuthDataProvider {}}+ /**+ * Get the access token from the authorization server.+ *+ * @return The access token.+ */protected abstract String getAccessToken();interface Builder<SELF extends Builder<SELF, T>, T extends OAuth2TokenProvider> {@@ -74,6 +80,7 @@ public abstract class OAuth2TokenProvider implements AuthDataProvider {implements Builder<SELF, T> {private String uri;+ /** The HTTP client used to request the access token from the authorization server. */protected HTTPClient client;/**@@ -105,6 +112,11 @@ public abstract class OAuth2TokenProvider implements AuthDataProvider {return (SELF) this;}+ /**+ * Builds the instance of the OAuth2TokenProvider.+ *+ * @return The built OAuth2TokenProvider instance.+ */protected abstract T internalBuild();}}diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/RESTClient.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/RESTClient.javaindex da0799eb97..271baafe32 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/RESTClient.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/RESTClient.java@@ -46,6 +46,13 @@ public interface RESTClient extends Closeable {head(path, headers.get(), errorHandler);}+ /**+ * Perform a HEAD request on the specified path with the given headers and error handling.+ *+ * @param path The path to be requested.+ * @param headers The headers to be included in the request.+ * @param errorHandler The consumer for handling error responses.+ */void head(String path, Map<String, String> headers, Consumer<ErrorResponse> errorHandler);/**@@ -265,6 +272,17 @@ public interface RESTClient extends Closeable {return post(path, body, responseType, headers, errorHandler);}+ /**+ * Perform a POST request on the specified path with given information.+ *+ * @param path The path to be requested.+ * @param body The request body to be included in the POST request.+ * @param responseType The class representing the type of the response.+ * @param headers The headers to be included in the request.+ * @param errorHandler The consumer for handling error responses.+ * @return The response of the POST request.+ * @param <T> The type of the response.+ */<T extends RESTResponse> T post(String path,RESTRequest body,@@ -343,6 +361,17 @@ public interface RESTClient extends Closeable {return put(path, body, responseType, headers, errorHandler);}+ /**+ * Perform a PUT request on the specified path with given information.+ *+ * @param path The path to be requested.+ * @param body The request body to be included in the PUT request.+ * @param responseType The class representing the type of the response.+ * @param headers The headers to be included in the request.+ * @param errorHandler The consumer for handling error responses.+ * @return The response of the PUT request.+ * @param <T> The type of the response.+ */<T extends RESTResponse> T put(String path,RESTRequest body,@@ -370,6 +399,17 @@ public interface RESTClient extends Closeable {return postForm(path, formData, responseType, headers.get(), errorHandler);}+ /**+ * Perform a POST request with form data on the specified path with the given information.+ *+ * @param path The path to be requested.+ * @param formData The form data to be included in the POST request body.+ * @param responseType The class representing the type of the response.+ * @param headers The headers to be included in the request.+ * @param errorHandler The consumer for handling error responses.+ * @return The response of the POST request.+ * @param <T> The type of the response.+ */<T extends RESTResponse> T postForm(String path,Map<String, String> formData,diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/RelationalTable.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/RelationalTable.javaindex 9dd4ee4d13..3036c498c7 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/RelationalTable.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/RelationalTable.java@@ -32,8 +32,17 @@ import java.util.Map;import javax.annotation.Nullable;import lombok.SneakyThrows;+/** Represents a relational table. */public class RelationalTable implements Table, SupportsPartitions {+ /**+ * Creates a new RelationalTable.+ *+ * @param namespace The namespace of the table.+ * @param tableDTO The table data transfer object.+ * @param restClient The REST client.+ * @return A new RelationalTable.+ */public static RelationalTable from(Namespace namespace, TableDTO tableDTO, RESTClient restClient) {return new RelationalTable(namespace, tableDTO, restClient);@@ -43,62 +52,88 @@ public class RelationalTable implements Table, SupportsPartitions {private final RESTClient restClient;private final Namespace namespace;+ /**+ * Creates a new RelationalTable.+ *+ * @param namespace The namespace of the table.+ * @param tableDTO The table data transfer object.+ * @param restClient The REST client.+ */public RelationalTable(Namespace namespace, TableDTO tableDTO, RESTClient restClient) {this.namespace = namespace;this.tableDTO = tableDTO;this.restClient = restClient;}+ /**+ * Returns the namespace of the table.+ *+ * @return The namespace of the table.+ */public Namespace namespace() {return namespace;}+ /**+ * Returns the name of the table.+ *+ * @return The name of the table.+ */@Overridepublic String name() {return tableDTO.name();}+ /** @return the columns of the table. */@Overridepublic Column[] columns() {return tableDTO.columns();}+ /** @return the partitioning of the table. */@Overridepublic Transform[] partitioning() {return tableDTO.partitioning();}+ /** @return the sort order of the table. */@Overridepublic SortOrder[] sortOrder() {return tableDTO.sortOrder();}+ /** @return the distribution of the table. */@Overridepublic Distribution distribution() {return tableDTO.distribution();}+ /** @return the comment of the table. */@Nullable@Overridepublic String comment() {return tableDTO.comment();}+ /** @return the properties of the table. */@Overridepublic Map<String, String> properties() {return tableDTO.properties();}+ /** @return the audit information of the table. */@Overridepublic Audit auditInfo() {return tableDTO.auditInfo();}+ /** @return the indexes of the table. */@Overridepublic Index[] index() {return tableDTO.index();}+ /** @return The partition names of the table. */@Overridepublic String[] listPartitionNames() {PartitionNameListResponse resp =@@ -110,6 +145,7 @@ public class RelationalTable implements Table, SupportsPartitions {return resp.partitionNames();}+ /** @return The partition request path. */@VisibleForTestingpublic String getPartitionRequestPath() {return "api/metalakes/"@@ -123,6 +159,7 @@ public class RelationalTable implements Table, SupportsPartitions {+ "/partitions";}+ /** @return The partitions of the table. */@Overridepublic Partition[] listPartitions() {Map<String, String> params = new HashMap<>();@@ -137,6 +174,13 @@ public class RelationalTable implements Table, SupportsPartitions {return resp.getPartitions();}+ /**+ * Returns the partition with the given name.+ *+ * @param partitionName the name of the partition+ * @return the partition with the given name+ * @throws NoSuchPartitionException if the partition does not exist, throws this exception.+ */@Overridepublic Partition getPartition(String partitionName) throws NoSuchPartitionException {PartitionResponse resp =@@ -148,6 +192,13 @@ public class RelationalTable implements Table, SupportsPartitions {return resp.getPartition();}+ /**+ * Adds a partition to the table.+ *+ * @param partition The partition to add.+ * @return The added partition.+ * @throws PartitionAlreadyExistsException If the partition already exists, throws this exception.+ */@Overridepublic Partition addPartition(Partition partition) throws PartitionAlreadyExistsException {AddPartitionsRequest req = new AddPartitionsRequest(new PartitionDTO[] {toDTO(partition)});@@ -165,16 +216,34 @@ public class RelationalTable implements Table, SupportsPartitions {return resp.getPartitions()[0];}+ /**+ * Drops the partition with the given name.+ *+ * @param partitionName The identifier of the partition.+ * @return true if the partition is dropped, false otherwise.+ */@Overridepublic boolean dropPartition(String partitionName) {throw new UnsupportedOperationException();}+ /**+ * Returns the partitioning strategy of the table.+ *+ * @return the partitioning strategy of the table.+ */@Overridepublic SupportsPartitions supportPartitions() throws UnsupportedOperationException {return this;}+ /**+ * Formats the partition request path.+ *+ * @param prefix The prefix of the path.+ * @param partitionName The name of the partition.+ * @return The formatted partition request path.+ */@VisibleForTesting@SneakyThrows // Encode charset is fixed to UTF-8, so this is safe.protected static String formatPartitionRequestPath(String prefix, String partitionName) {diff --git a/common/src/main/java/com/datastrato/gravitino/auth/KerberosUtils.java b/common/src/main/java/com/datastrato/gravitino/auth/KerberosUtils.javaindex 6a83519dad..c99150ad67 100644--- a/common/src/main/java/com/datastrato/gravitino/auth/KerberosUtils.java+++ b/common/src/main/java/com/datastrato/gravitino/auth/KerberosUtils.java@@ -37,12 +37,19 @@ import org.ietf.jgss.Oid;// Split method `doAs` into two methods// hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/\// authentication/KerberosTestUtils.java++/** Utility class for Kerberos related tests. */public class KerberosUtils {private KerberosUtils() {}+ /** Oid instance for Kerberos spnego mechanism. */public static final Oid GSS_SPNEGO_MECH_OID = getNumericOidInstance("1.3.6.1.5.5.2");++ /** Oid instance for Kerberos mechanism. */public static final Oid GSS_KRB5_MECH_OID = getNumericOidInstance("1.2.840.113554.1.2.2");++ /** Oid instance for Kerberos principal name. */public static final Oid NT_GSS_KRB5_PRINCIPAL_OID =getNumericOidInstance("1.2.840.113554.1.2.2.1");@@ -56,6 +63,14 @@ public class KerberosUtils {}}+ /**+ * Login to KDC using principal and keytab file.+ *+ * @param principal The principal name+ * @param keyTabFile The keytab file+ * @return The login context+ * @throws LoginException If login fails, or if the principal and keytab file are invalid.+ */public static LoginContext login(String principal, String keyTabFile) throws LoginException {Set<Principal> principals = new HashSet<>();principals.add(new KerberosPrincipal(principal));@@ -66,6 +81,15 @@ public class KerberosUtils {return loginContext;}+ /**+ * Execute the given action as the given subject.+ *+ * @param subject The subject to execute the action as.+ * @param callable The action to execute.+ * @param <T> The return type of the action+ * @return The result of the action+ * @throws Exception If the action throws an exception+ */public static <T> T doAs(Subject subject, final Callable<T> callable) throws Exception {try {return Subject.doAs(@@ -121,7 +145,7 @@ public class KerberosUtils {}}- /* Return the Kerberos login module name */+ /** @return The Kerberos login module name. */public static String getKrb5LoginModuleName() {return "com.sun.security.auth.module.Krb5LoginModule";}diff --git a/common/src/main/java/com/datastrato/gravitino/auth/SignatureAlgorithmFamilyType.java b/common/src/main/java/com/datastrato/gravitino/auth/SignatureAlgorithmFamilyType.javaindex bce462c39d..bc2a9c4861 100644--- a/common/src/main/java/com/datastrato/gravitino/auth/SignatureAlgorithmFamilyType.java+++ b/common/src/main/java/com/datastrato/gravitino/auth/SignatureAlgorithmFamilyType.java@@ -5,8 +5,14 @@package com.datastrato.gravitino.auth;+/** Represents the type of signature algorithm family. */public enum SignatureAlgorithmFamilyType {+ /** HMAC family of algorithms. */HMAC,++ /** RSA family of algorithms. */RSA,++ /** ECDSA family of algorithms. */ECDSA}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/AuditDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/AuditDTO.javaindex 366f1cc749..4044ab2e47 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/AuditDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/AuditDTO.java@@ -37,21 +37,25 @@ public class AuditDTO implements Audit {this.lastModifiedTime = lastModifiedTime;}+ /** @return The creator of the audit. */@Overridepublic String creator() {return creator;}+ /** @return The create time of the audit. */@Overridepublic Instant createTime() {return createTime;}+ /** @return The last modifier of the audit. */@Overridepublic String lastModifier() {return lastModifier;}+ /** @return The last modified time of the audit. */@Overridepublic Instant lastModifiedTime() {return lastModifiedTime;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/CatalogDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/CatalogDTO.javaindex b29998e8f1..08f94c3299 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/CatalogDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/CatalogDTO.java@@ -152,6 +152,7 @@ public class CatalogDTO implements Catalog {/** The audit information of the catalog. */protected AuditDTO audit;+ /** Default constructor for the builder. */public Builder() {}/**diff --git a/common/src/main/java/com/datastrato/gravitino/dto/MetalakeDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/MetalakeDTO.javaindex ef4cd90612..c341b7794b 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/MetalakeDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/MetalakeDTO.java@@ -31,8 +31,17 @@ public class MetalakeDTO implements Metalake {@JsonProperty("audit")private AuditDTO audit;+ /** Default constructor for Jackson deserialization. */protected MetalakeDTO() {}+ /**+ * Creates a new instance of MetalakeDTO.+ *+ * @param name The name of the Metalake DTO.+ * @param comment The comment of the Metalake DTO.+ * @param properties The properties of the Metalake DTO.+ * @param audit The audit information of the Metalake DTO.+ */protected MetalakeDTO(String name, String comment, Map<String, String> properties, AuditDTO audit) {this.name = name;@@ -41,21 +50,25 @@ public class MetalakeDTO implements Metalake {this.audit = audit;}+ /** @return The name of the Metalake DTO. */@Overridepublic String name() {return name;}+ /** @return The comment of the Metalake DTO. */@Overridepublic String comment() {return comment;}+ /** @return The properties of the Metalake DTO. */@Overridepublic Map<String, String> properties() {return properties;}+ /** @return The audit information of the Metalake DTO. */@Overridepublic Audit auditInfo() {return audit;@@ -68,11 +81,19 @@ public class MetalakeDTO implements Metalake {*/public static class Builder<S extends Builder> {+ /** The name of the Metalake DTO. */protected String name;++ /** The comment of the Metalake DTO. */protected String comment;++ /** The properties of the Metalake DTO. */protected Map<String, String> properties;++ /** The audit information of the Metalake DTO. */protected AuditDTO audit;+ /** Default constructor. */public Builder() {}/**diff --git a/common/src/main/java/com/datastrato/gravitino/dto/VersionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/VersionDTO.javaindex 47de01a103..a8c4ff1f8b 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/VersionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/VersionDTO.java@@ -22,26 +22,37 @@ public class VersionDTO {@JsonProperty("gitCommit")private final String gitCommit;+ /** Default constructor for Jackson deserialization. */public VersionDTO() {this.version = "";this.compileDate = "";this.gitCommit = "";}+ /**+ * Creates a new instance of VersionDTO.+ *+ * @param version The version of the software.+ * @param compileDate The date the software was compiled.+ * @param gitCommit The git commit of the software.+ */public VersionDTO(String version, String compileDate, String gitCommit) {this.version = version;this.compileDate = compileDate;this.gitCommit = gitCommit;}+ /** @return The version of the software. */public String version() {return version;}+ /** @return The date the software was compiled. */public String compileDate() {return compileDate;}+ /** @return The git commit of the software. */public String gitCommit() {return gitCommit;}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/ColumnDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/ColumnDTO.javaindex 8a35fb475b..76544dc692 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/ColumnDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/ColumnDTO.java@@ -139,6 +139,7 @@ public class ColumnDTO implements Column {/** The default value of the column. */protected Expression defaultValue;+ /** Constructs a new Builder. */public Builder() {}/**@@ -196,6 +197,12 @@ public class ColumnDTO implements Column {return (S) this;}+ /**+ * Sets the default value of the column.+ *+ * @param defaultValue The default value of the column.+ * @return The Builder instance.+ */public S withDefaultValue(Expression defaultValue) {this.defaultValue = defaultValue;return (S) this;@@ -205,7 +212,7 @@ public class ColumnDTO implements Column {* Builds a Column DTO based on the provided builder parameters.** @return A new ColumnDTO instance.- * @throws NullPointerException If required fields name and data type are not set.+ * @throws NullPointerException If required, fields name and data type are not set.*/public ColumnDTO build() {Preconditions.checkNotNull(name, "Column name cannot be null");@@ -214,6 +221,12 @@ public class ColumnDTO implements Column {}}+ /**+ * Validates the Column DTO.+ *+ * @throws IllegalArgumentException If some of the required fields are not set or if the column is+ * non-nullable with a null default value, this method will throw an IllegalArgumentException.+ */public void validate() throws IllegalArgumentException {if (name() == null || name().isEmpty()) {throw new IllegalArgumentException("Column name cannot be null or empty.");diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/DistributionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/DistributionDTO.javaindex 838a79a4c7..6060159752 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/DistributionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/DistributionDTO.java@@ -26,6 +26,11 @@ public class DistributionDTO implements Distribution {public static final DistributionDTO NONE =builder().withStrategy(Strategy.NONE).withNumber(0).withArgs(EMPTY_ARGS).build();+ /**+ * Creates a new instance of {@link Builder}.+ *+ * @return The new instance.+ */public static Builder builder() {return new Builder();}@@ -44,25 +49,51 @@ public class DistributionDTO implements Distribution {this.strategy = strategy;}+ /**+ * Returns the arguments of the function.+ *+ * @return The arguments of the function.+ */public FunctionArg[] args() {return args;}+ /**+ * Returns the strategy of the distribution.+ *+ * @return The strategy of the distribution.+ */@Overridepublic Strategy strategy() {return strategy;}+ /**+ * Returns the number of buckets.+ *+ * @return The number of buckets.+ */@Overridepublic int number() {return number;}+ /**+ * Returns the name of the distribution.+ *+ * @return The name of the distribution.+ */@Overridepublic Expression[] expressions() {return args;}+ /**+ * Validates the distribution.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the distribution is invalid.+ */public void validate(ColumnDTO[] columns) throws IllegalArgumentException {Arrays.stream(args).forEach(expression -> expression.validate(columns));}@@ -73,23 +104,47 @@ public class DistributionDTO implements Distribution {private int number = 0;private Strategy strategy;+ /** Creates a new instance of {@link Builder}. */public Builder() {}+ /**+ * Sets the arguments of the function.+ *+ * @param args The arguments of the function.+ * @return The builder.+ */public Builder withArgs(FunctionArg... args) {this.args = args;return this;}+ /**+ * Sets the number of buckets.+ *+ * @param bucketNum The number of buckets.+ * @return The builder.+ */public Builder withNumber(int bucketNum) {this.number = bucketNum;return this;}+ /**+ * Sets the strategy of the distribution.+ *+ * @param strategy The strategy of the distribution.+ * @return The builder.+ */public Builder withStrategy(Strategy strategy) {this.strategy = strategy;return this;}+ /**+ * Builds a new instance of {@link DistributionDTO}.+ *+ * @return The new instance.+ */public DistributionDTO build() {strategy = strategy == null ? Strategy.HASH : strategy;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/PartitionUtils.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/PartitionUtils.javaindex 51d7601c0d..e79c8df0db 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/PartitionUtils.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/PartitionUtils.java@@ -10,8 +10,17 @@ import java.util.List;import java.util.stream.Collectors;import org.apache.commons.lang3.ArrayUtils;+/** Utility class for partitioning validation. */public class PartitionUtils {+ /**+ * Validates the existence of the partition field in the table.+ *+ * @param columns The columns of the table.+ * @param fieldName The name of the field to validate.+ * @throws IllegalArgumentException If the field does not exist in the table, this exception is+ * thrown.+ */public static void validateFieldExistence(ColumnDTO[] columns, String[] fieldName)throws IllegalArgumentException {Preconditions.checkArgument(ArrayUtils.isNotEmpty(columns), "columns cannot be null or empty");diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/SchemaDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/SchemaDTO.javaindex 1d340a8a08..fc9f32854f 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/SchemaDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/SchemaDTO.java@@ -42,21 +42,25 @@ public class SchemaDTO implements Schema {this.audit = audit;}+ /** @return The name of the schema. */@Overridepublic String name() {return name;}+ /** @return The comment associated with the schema. */@Overridepublic String comment() {return comment;}+ /** @return The properties associated with the schema. */@Overridepublic Map<String, String> properties() {return properties;}+ /** @return The audit information for the schema. */@Overridepublic AuditDTO auditInfo() {return audit;@@ -68,11 +72,16 @@ public class SchemaDTO implements Schema {* @param <S> The type of the builder subclass.*/public static class Builder<S extends Builder> {+ /** The name of the schema. */protected String name;+ /** The comment associated with the schema. */protected String comment;+ /** The properties associated with the schema. */protected Map<String, String> properties;+ /** The audit information for the schema. */protected AuditDTO audit;+ /** Constructs a new Builder instance. */public Builder() {}/**diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/SortOrderDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/SortOrderDTO.javaindex 19074dfc6b..169667449b 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/SortOrderDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/SortOrderDTO.java@@ -16,10 +16,13 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;import com.google.common.base.Preconditions;import lombok.EqualsAndHashCode;+/** Data Transfer Object for SortOrder. */@EqualsAndHashCode@JsonSerialize(using = JsonUtils.SortOrderSerializer.class)@JsonDeserialize(using = JsonUtils.SortOrderDeserializer.class)public class SortOrderDTO implements SortOrder {++ /** An empty array of SortOrderDTO. */public static final SortOrderDTO[] EMPTY_SORT = new SortOrderDTO[0];private final FunctionArg sortTerm;@@ -34,51 +37,86 @@ public class SortOrderDTO implements SortOrder {this.nullOrdering = nullOrdering;}+ /** @return The sort term. */public FunctionArg sortTerm() {return sortTerm;}+ /** @return The sort expression. */@Overridepublic Expression expression() {return sortTerm;}+ /** @return The sort direction. */@Overridepublic SortDirection direction() {return direction;}+ /** @return The null ordering. */@Overridepublic NullOrdering nullOrdering() {return nullOrdering;}+ /**+ * Validates the sort order.+ *+ * @param columns The column DTOs to validate against.+ * @throws IllegalArgumentException If the sort order is invalid, this exception is thrown.+ */public void validate(ColumnDTO[] columns) throws IllegalArgumentException {sortTerm.validate(columns);}+ /** Builder for SortOrderDTO. */public static class Builder {private FunctionArg sortTerm;private SortDirection direction;private NullOrdering nullOrdering;+ /** Default constructor. */public Builder() {}+ /**+ * Set the sort term.+ *+ * @param sortTerm The sort term to set.+ * @return The builder.+ */public Builder withSortTerm(FunctionArg sortTerm) {this.sortTerm = sortTerm;return this;}+ /**+ * Set the sort direction.+ *+ * @param direction The sort direction to set.+ * @return The builder.+ */public Builder withDirection(SortDirection direction) {this.direction = direction;return this;}+ /**+ * Set the null ordering.+ *+ * @param nullOrdering The null ordering to set.+ * @return The builder.+ */public Builder withNullOrder(NullOrdering nullOrdering) {this.nullOrdering = nullOrdering;return this;}+ /**+ * Builds a SortOrderDTO based on the provided builder parameters.+ *+ * @return A new SortOrderDTO instance.+ */public SortOrderDTO build() {// Default direction is ASCthis.direction = direction == null ? SortDirection.ASCENDING : direction;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/TableDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/TableDTO.javaindex cb893ef63f..0fa783b1f6 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/TableDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/TableDTO.java@@ -81,46 +81,55 @@ public class TableDTO implements Table {this.indexes = indexes;}+ /** @return The name of the table. */@Overridepublic String name() {return name;}+ /** @return The columns of the table. */@Overridepublic Column[] columns() {return columns;}+ /** @return The comment associated with the table. */@Overridepublic String comment() {return comment;}+ /** @return The properties associated with the table. */@Overridepublic Map<String, String> properties() {return properties;}+ /** @return The audit information for the table. */@Overridepublic AuditDTO auditInfo() {return audit;}+ /** @return The partitioning of the table. */@Overridepublic Transform[] partitioning() {return partitioning;}+ /** @return The sort orders of the table. */@Overridepublic SortOrder[] sortOrder() {return sortOrders;}+ /** @return The distribution of the table. */@Overridepublic Distribution distribution() {return distribution;}+ /** @return The indexes of the table. */@Overridepublic Index[] index() {return indexes;@@ -141,16 +150,26 @@ public class TableDTO implements Table {* @param <S> The type of the builder subclass.*/public static class Builder<S extends Builder> {+ /** The name of the table. */protected String name;+ /** The comment associated with the table. */protected String comment;+ /** The columns of the table. */protected ColumnDTO[] columns;+ /** The properties associated with the table. */protected Map<String, String> properties;+ /** The audit information for the table. */protected AuditDTO audit;+ /** The distribution of the table. */protected SortOrderDTO[] sortOrderDTOs;+ /** The distribution of the table. */protected DistributionDTO distributionDTO;+ /** The partitioning of the table. */protected Partitioning[] Partitioning;+ /** The indexes of the table. */protected IndexDTO[] indexes;+ /** Default constructor. */public Builder() {}/**@@ -208,21 +227,45 @@ public class TableDTO implements Table {return (S) this;}+ /**+ * Sets the distribution of the table.+ *+ * @param distributionDTO The distribution of the table.+ * @return The Builder instance.+ */public S withDistribution(DistributionDTO distributionDTO) {this.distributionDTO = distributionDTO;return (S) this;}+ /**+ * Sets the sort orders of the table.+ *+ * @param sortOrderDTOs The sort orders of the table.+ * @return The Builder instance.+ */public S withSortOrders(SortOrderDTO[] sortOrderDTOs) {this.sortOrderDTOs = sortOrderDTOs;return (S) this;}+ /**+ * Sets the partitioning of the table.+ *+ * @param Partitioning The partitioning of the table.+ * @return The Builder instance.+ */public S withPartitioning(Partitioning[] Partitioning) {this.Partitioning = Partitioning;return (S) this;}+ /**+ * Sets the indexes of the table.+ *+ * @param indexes The indexes of the table.+ * @return The Builder instance.+ */public S withIndex(IndexDTO[] indexes) {this.indexes = indexes;return (S) this;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FieldReferenceDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FieldReferenceDTO.javaindex 47c583c04f..5994f83aa5 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FieldReferenceDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FieldReferenceDTO.java@@ -7,9 +7,16 @@ package com.datastrato.gravitino.dto.rel.expressions;import com.datastrato.gravitino.rel.expressions.NamedReference;import lombok.EqualsAndHashCode;+/** Data transfer object representing a field reference. */@EqualsAndHashCodepublic class FieldReferenceDTO implements FunctionArg, NamedReference {+ /**+ * Creates a new instance of {@link FieldReferenceDTO}.+ *+ * @param fieldName The field name.+ * @return The new instance.+ */public static FieldReferenceDTO of(String... fieldName) {return new FieldReferenceDTO(fieldName);}@@ -20,29 +27,49 @@ public class FieldReferenceDTO implements FunctionArg, NamedReference {this.fieldName = fieldName;}+ /** @return The field name. */@Overridepublic String[] fieldName() {return fieldName;}+ /** @return The name of the field reference. */@Overridepublic ArgType argType() {return ArgType.FIELD;}+ /** Builder for {@link FieldReferenceDTO}. */public static class Builder {private String[] fieldName;+ /**+ * Set the field name for the field reference.+ *+ * @param fieldName The field name.+ * @return The builder.+ */public Builder withFieldName(String[] fieldName) {this.fieldName = fieldName;return this;}+ /**+ * Set the column name for the field reference.+ *+ * @param columnName The column name.+ * @return The builder.+ */public Builder withColumnName(String columnName) {this.fieldName = new String[] {columnName};return this;}+ /**+ * Build the field reference.+ *+ * @return The field reference.+ */public FieldReferenceDTO build() {return new FieldReferenceDTO(fieldName);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FuncExpressionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FuncExpressionDTO.javaindex 2b21bfd817..0961b12aea 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FuncExpressionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FuncExpressionDTO.java@@ -8,6 +8,7 @@ import com.datastrato.gravitino.rel.expressions.Expression;import com.datastrato.gravitino.rel.expressions.FunctionExpression;import lombok.EqualsAndHashCode;+/** Data transfer object representing a function expression. */@EqualsAndHashCodepublic class FuncExpressionDTO implements FunctionExpression, FunctionArg {private final String functionName;@@ -18,39 +19,61 @@ public class FuncExpressionDTO implements FunctionExpression, FunctionArg {this.functionArgs = functionArgs;}+ /** @return The function arguments. */public FunctionArg[] args() {return functionArgs;}+ /** @return The function name. */@Overridepublic String functionName() {return functionName;}+ /** @return The function arguments. */@Overridepublic Expression[] arguments() {return functionArgs;}+ /** @return The type of the function argument. */@Overridepublic ArgType argType() {return ArgType.FUNCTION;}+ /** Builder for {@link FuncExpressionDTO}. */public static class Builder {private String functionName;private FunctionArg[] functionArgs;+ /**+ * Set the function name for the function expression.+ *+ * @param functionName The function name.+ * @return The builder.+ */public Builder withFunctionName(String functionName) {this.functionName = functionName;return this;}+ /**+ * Set the function arguments for the function expression.+ *+ * @param functionArgs The function arguments.+ * @return The builder.+ */public Builder withFunctionArgs(FunctionArg... functionArgs) {this.functionArgs = functionArgs;return this;}+ /**+ * Builds the function expression.+ *+ * @return The function expression.+ */public FuncExpressionDTO build() {return new FuncExpressionDTO(functionName, functionArgs);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FunctionArg.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FunctionArg.javaindex 7a6d6125eb..5d32a42aab 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FunctionArg.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/FunctionArg.java@@ -10,20 +10,41 @@ import com.datastrato.gravitino.dto.rel.ColumnDTO;import com.datastrato.gravitino.rel.expressions.Expression;import java.util.Arrays;+/** An argument of a function. */public interface FunctionArg extends Expression {+ /** Constant for an empty array of function arguments. */FunctionArg[] EMPTY_ARGS = new FunctionArg[0];+ /**+ * Arguments type of the function.+ *+ * @return The type of the argument.+ */ArgType argType();+ /**+ * Validates the function argument.+ *+ * @param columns The columns of the table.+ * @throws IllegalArgumentException If the function argument is invalid.+ */default void validate(ColumnDTO[] columns) throws IllegalArgumentException {Arrays.stream(references()).forEach(ref -> validateFieldExistence(columns, ref.fieldName()));}+ /** The type of the argument. */enum ArgType {+ /** A literal argument. */LITERAL,++ /** * A field argument. */FIELD,++ /** A function argument. */FUNCTION,++ /** An argument that cannot be parsed. */UNPARSED}}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/LiteralDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/LiteralDTO.javaindex aac54444b9..871a9c240a 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/LiteralDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/LiteralDTO.java@@ -9,9 +9,11 @@ import com.datastrato.gravitino.rel.types.Type;import com.datastrato.gravitino.rel.types.Types;import lombok.EqualsAndHashCode;+/** Represents a Literal Data Transfer Object (DTO) that implements the Literal interface. */@EqualsAndHashCodepublic class LiteralDTO implements Literal<String>, FunctionArg {+ /** A instance of LiteralDTO with a value of "NULL" and a data type of Types.NullType.get(). */public static final LiteralDTO NULL = new LiteralDTO("NULL", Types.NullType.get());private final String value;@@ -22,16 +24,19 @@ public class LiteralDTO implements Literal<String>, FunctionArg {this.dataType = dataType;}+ /** @return The value of the literal. */@Overridepublic String value() {return value;}+ /** @return The data type of the literal. */@Overridepublic Type dataType() {return dataType;}+ /** @return The type of the argument. */@Overridepublic ArgType argType() {return ArgType.LITERAL;@@ -42,20 +47,38 @@ public class LiteralDTO implements Literal<String>, FunctionArg {return "LiteralDTO{" + "value='" + value + '\'' + ", dataType=" + dataType + '}';}+ /** Builder for LiteralDTO. */public static class Builder {private String value;private Type dataType;+ /**+ * Set the value of the literal.+ *+ * @param value The value of the literal.+ * @return The builder.+ */public Builder withValue(String value) {this.value = value;return this;}+ /**+ * Set the data type of the literal.+ *+ * @param dataType The data type of the literal.+ * @return The builder.+ */public Builder withDataType(Type dataType) {this.dataType = dataType;return this;}+ /**+ * Builds a LiteralDTO instance.+ *+ * @return The LiteralDTO instance.+ */public LiteralDTO build() {return new LiteralDTO(value, dataType);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/UnparsedExpressionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/UnparsedExpressionDTO.javaindex fb5420b33f..a631e702c1 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/UnparsedExpressionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/expressions/UnparsedExpressionDTO.java@@ -9,6 +9,7 @@ import static com.datastrato.gravitino.dto.rel.expressions.FunctionArg.ArgType.Uimport com.datastrato.gravitino.rel.expressions.UnparsedExpression;import lombok.EqualsAndHashCode;+/** Data transfer object representing an unparsed expression. */@EqualsAndHashCodepublic class UnparsedExpressionDTO implements UnparsedExpression, FunctionArg {@@ -18,11 +19,13 @@ public class UnparsedExpressionDTO implements UnparsedExpression, FunctionArg {this.unparsedExpression = unparsedExpression;}+ /** @return The value of the unparsed expression. */@Overridepublic String unparsedExpression() {return unparsedExpression;}+ /** @return The type of the function argument. */@Overridepublic ArgType argType() {return UNPARSED;@@ -33,18 +36,31 @@ public class UnparsedExpressionDTO implements UnparsedExpression, FunctionArg {return "UnparsedExpressionDTO{" + "unparsedExpression='" + unparsedExpression + '\'' + '}';}+ /** @return A builder instance for {@link UnparsedExpressionDTO}. */public static Builder builder() {return new Builder();}+ /** Builder for {@link UnparsedExpressionDTO}. */public static class Builder {private String unparsedExpression;+ /**+ * Set the unparsed expression.+ *+ * @param unparsedExpression The unparsed expression.+ * @return The builder.+ */public Builder withUnparsedExpression(String unparsedExpression) {this.unparsedExpression = unparsedExpression;return this;}+ /**+ * Build the unparsed expression.+ *+ * @return The unparsed expression.+ */public UnparsedExpressionDTO build() {return new UnparsedExpressionDTO(unparsedExpression);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/indexes/IndexDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/indexes/IndexDTO.javaindex e85984b9de..038d2997f3 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/indexes/IndexDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/indexes/IndexDTO.java@@ -12,34 +12,47 @@ import com.google.common.base.Preconditions;import java.util.Arrays;import java.util.Objects;+/** Data transfer object representing index information. */@JsonSerialize(using = JsonUtils.IndexSerializer.class)@JsonDeserialize(using = JsonUtils.IndexDeserializer.class)public class IndexDTO implements Index {+ /** An empty array of indexes. */public static final IndexDTO[] EMPTY_INDEXES = new IndexDTO[0];private IndexType indexType;private String name;private String[][] fieldNames;+ /** Default constructor for Jackson deserialization. */public IndexDTO() {}+ /**+ * Creates a new instance of IndexDTO+ *+ * @param indexType The type of the index.+ * @param name The name of the index.+ * @param fieldNames The names of the fields.+ */public IndexDTO(IndexType indexType, String name, String[][] fieldNames) {this.indexType = indexType;this.name = name;this.fieldNames = fieldNames;}+ /** @return The type of the index. */@Overridepublic IndexType type() {return indexType;}+ /** @return The name of the index. */@Overridepublic String name() {return name;}+ /** @return The field name under the table contained in the index. */@Overridepublic String[][] fieldNames() {return fieldNames;@@ -56,7 +69,7 @@ public class IndexDTO implements Index {&& compareStringArrays(fieldNames, indexDTO.fieldNames);}- public static boolean compareStringArrays(String[][] array1, String[][] array2) {+ private static boolean compareStringArrays(String[][] array1, String[][] array2) {if (array1.length != array2.length) {return false;}@@ -75,34 +88,67 @@ public class IndexDTO implements Index {return result;}+ /**+ * Get the builder for creating a new instance of IndexDTO.+ *+ * @return The builder.+ */public static Builder builder() {return new Builder();}+ /** Builder for creating a new instance of IndexDTO. */public static class Builder<S extends IndexDTO.Builder> {+ /** The type of the index. */protected IndexType indexType;+ /** The name of the index. */protected String name;+ /** The names of the fields. */protected String[][] fieldNames;+ /** Default constructor. */public Builder() {}+ /**+ * Sets the type of the index.+ *+ * @param indexType The type of the index.+ * @return The builder.+ */public S withIndexType(IndexType indexType) {this.indexType = indexType;return (S) this;}+ /**+ * Sets the name of the index.+ *+ * @param name The name of the index.+ * @return The builder.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the field names of the index.+ *+ * @param fieldNames The field names of the index.+ * @return The builder.+ */public S withFieldNames(String[][] fieldNames) {this.fieldNames = fieldNames;return (S) this;}+ /**+ * Builds a new instance of IndexDTO.+ *+ * @return The new instance.+ */public IndexDTO build() {Preconditions.checkArgument(indexType != null, "Index type cannot be null");Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/BucketPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/BucketPartitioningDTO.javaindex 2636f3119a..3efc48152f 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/BucketPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/BucketPartitioningDTO.java@@ -53,21 +53,30 @@ public final class BucketPartitioningDTO implements Partitioning {return fieldNames;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.BUCKET;}+ /**+ * Validates the partitioning columns.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the columns are invalid, this exception is thrown.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {Arrays.stream(fieldNames).forEach(fieldName -> validateFieldExistence(columns, fieldName));}+ /** @return The name of the partitioning strategy. */@Overridepublic String name() {return strategy().name().toLowerCase();}+ /** @return The arguments of the partitioning strategy. */@Overridepublic Expression[] arguments() {return bucket(numBuckets, fieldNames).arguments();diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/DayPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/DayPartitioningDTO.javaindex 6dc7a7fd5b..ebd712cd6f 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/DayPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/DayPartitioningDTO.java@@ -28,6 +28,7 @@ public final class DayPartitioningDTO extends Partitioning.SingleFieldPartitionithis.fieldName = fieldName;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.DAY;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/FunctionPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/FunctionPartitioningDTO.javaindex f932ce119a..d0094d77a6 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/FunctionPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/FunctionPartitioningDTO.java@@ -12,9 +12,17 @@ import com.datastrato.gravitino.rel.expressions.Expression;import java.util.Arrays;import lombok.EqualsAndHashCode;+/** Data transfer object for function partitioning. */@EqualsAndHashCodepublic final class FunctionPartitioningDTO implements Partitioning {+ /**+ * Creates a new function partitioning DTO.+ *+ * @param functionName The name of the function.+ * @param args The arguments of the function.+ * @return The function partitioning DTO.+ */public static FunctionPartitioningDTO of(String functionName, FunctionArg... args) {return new FunctionPartitioningDTO(functionName, args);}@@ -27,29 +35,60 @@ public final class FunctionPartitioningDTO implements Partitioning {this.args = args;}+ /**+ * Returns the name of the function.+ *+ * @return The name of the function.+ */public String functionName() {return functionName;}+ /**+ * Returns the arguments of the function.+ *+ * @return The arguments of the function.+ */public FunctionArg[] args() {return args;}+ /**+ * Returns the name of the function.+ *+ * @return The name of the function.+ */@Overridepublic String name() {return functionName;}+ /**+ * Returns the arguments of the function.+ *+ * @return The arguments of the function.+ */@Overridepublic Expression[] arguments() {return args;}+ /**+ * Returns the strategy of the partitioning.+ *+ * @return The strategy of the partitioning.+ */@Overridepublic Strategy strategy() {return Strategy.FUNCTION;}+ /**+ * Validates the function partitioning.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the function partitioning is invalid.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {Arrays.stream(references()).forEach(ref -> validateFieldExistence(columns, ref.fieldName()));diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/HourPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/HourPartitioningDTO.javaindex ab5385885d..7c9c76fa16 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/HourPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/HourPartitioningDTO.java@@ -7,7 +7,15 @@ package com.datastrato.gravitino.dto.rel.partitioning;import com.google.common.base.Preconditions;import org.apache.commons.lang3.ArrayUtils;+/** Represents the hour partitioning. */public final class HourPartitioningDTO extends Partitioning.SingleFieldPartitioning {++ /**+ * Creates a new HourPartitioningDTO.+ *+ * @param fieldName The name of the field to partition.+ * @return The new HourPartitioningDTO.+ */public static HourPartitioningDTO of(String[] fieldName) {return new HourPartitioningDTO(fieldName);}@@ -18,6 +26,7 @@ public final class HourPartitioningDTO extends Partitioning.SingleFieldPartitionthis.fieldName = fieldName;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.HOUR;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/IdentityPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/IdentityPartitioningDTO.javaindex 00c1278a2e..60b83423b8 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/IdentityPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/IdentityPartitioningDTO.java@@ -8,9 +8,16 @@ import com.google.common.base.Preconditions;import lombok.EqualsAndHashCode;import org.apache.commons.lang3.ArrayUtils;+/** Represents the identity partitioning. */@EqualsAndHashCode(callSuper = true)public final class IdentityPartitioningDTO extends Partitioning.SingleFieldPartitioning {+ /**+ * Creates a new IdentityPartitioningDTO.+ *+ * @param fieldName The name of the field to partition.+ * @return The new IdentityPartitioningDTO.+ */public static IdentityPartitioningDTO of(String... fieldName) {return new IdentityPartitioningDTO(fieldName);}@@ -21,6 +28,7 @@ public final class IdentityPartitioningDTO extends Partitioning.SingleFieldPartithis.fieldName = fieldName;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.IDENTITY;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/ListPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/ListPartitioningDTO.javaindex 484253c74f..7a53fa7e96 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/ListPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/ListPartitioningDTO.java@@ -12,9 +12,16 @@ import com.datastrato.gravitino.rel.expressions.NamedReference;import java.util.Arrays;import lombok.EqualsAndHashCode;+/** Data transfer object representing a list partitioning. */@EqualsAndHashCodepublic final class ListPartitioningDTO implements Partitioning {+ /**+ * Creates a new ListPartitioningDTO.+ *+ * @param fieldNames The names of the fields to partition.+ * @return The new ListPartitioningDTO.+ */public static ListPartitioningDTO of(String[][] fieldNames) {return new ListPartitioningDTO(fieldNames);}@@ -25,38 +32,60 @@ public final class ListPartitioningDTO implements Partitioning {this.fieldNames = fieldNames;}+ /** @return The names of the fields to partition. */public String[][] fieldNames() {return fieldNames;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.LIST;}+ /**+ * Validates the partitioning columns.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the columns are invalid, this exception is thrown.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {Arrays.stream(fieldNames).forEach(fieldName -> validateFieldExistence(columns, fieldName));}+ /** @return The name of the partitioning strategy. */@Overridepublic String name() {return strategy().name().toLowerCase();}+ /** @return The arguments of the partitioning strategy. */@Overridepublic Expression[] arguments() {return Arrays.stream(fieldNames).map(NamedReference::field).toArray(Expression[]::new);}+ /** The builder for ListPartitioningDTO. */public static class Builder {private String[][] fieldNames;+ /**+ * Set the field names for the builder.+ *+ * @param fieldNames The names of the fields to partition.+ * @return The builder.+ */public Builder withFieldNames(String[][] fieldNames) {this.fieldNames = fieldNames;return this;}+ /**+ * Builds the ListPartitioningDTO.+ *+ * @return The ListPartitioningDTO.+ */public ListPartitioningDTO build() {return new ListPartitioningDTO(fieldNames);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/MonthPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/MonthPartitioningDTO.javaindex 309380493e..a1f603dcd7 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/MonthPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/MonthPartitioningDTO.java@@ -7,7 +7,18 @@ package com.datastrato.gravitino.dto.rel.partitioning;import com.google.common.base.Preconditions;import org.apache.commons.lang3.ArrayUtils;+/**+ * Represents a MonthPartitioning Data Transfer Object (DTO) that extends the Partitioning+ * interface.+ */public final class MonthPartitioningDTO extends Partitioning.SingleFieldPartitioning {++ /**+ * Creates a new MonthPartitioningDTO.+ *+ * @param fieldName The name of the field to partition.+ * @return The new MonthPartitioningDTO.+ */public static MonthPartitioningDTO of(String[] fieldName) {return new MonthPartitioningDTO(fieldName);}@@ -18,6 +29,7 @@ public final class MonthPartitioningDTO extends Partitioning.SingleFieldPartitiothis.fieldName = fieldName;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.MONTH;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/Partitioning.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/Partitioning.javaindex 42bd4799a0..c53e99d584 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/Partitioning.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/Partitioning.java@@ -16,10 +16,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;import java.util.Arrays;import lombok.EqualsAndHashCode;+/**+ * A partitioning strategy is a way to divide a table into smaller, more manageable pieces. This+ * interface represents a partitioning strategy.+ */@JsonSerialize(using = JsonUtils.PartitioningSerializer.class)@JsonDeserialize(using = JsonUtils.PartitioningDeserializer.class)public interface Partitioning extends Transform {+ /** An empty array of partitioning. */Partitioning[] EMPTY_PARTITIONING = new Partitioning[0];/**@@ -37,18 +42,35 @@ public interface Partitioning extends Transform {*/void validate(ColumnDTO[] columns) throws IllegalArgumentException;+ /** Represents a partitioning strategy. */enum Strategy {+ /** The identity partitioning strategy. */IDENTITY,+ /** The year partitioning strategy. */YEAR,+ /** The month partitioning strategy. */MONTH,+ /** The day partitioning strategy. */DAY,+ /** The hour partitioning strategy. */HOUR,+ /** The minute partitioning strategy. */BUCKET,+ /** The truncate partitioning strategy. */TRUNCATE,+ /** The list partitioning strategy. */LIST,+ /** The range partitioning strategy. */RANGE,+ /** The hash partitioning strategy. */FUNCTION;+ /**+ * Get the partitioning strategy by name.+ *+ * @param name The name of the partitioning strategy.+ * @return The partitioning strategy.+ */public static Strategy getByName(String name) {for (Strategy strategy : Strategy.values()) {if (strategy.name().equalsIgnoreCase(name)) {@@ -63,24 +85,34 @@ public interface Partitioning extends Transform {}}+ /** A single field partitioning strategy. */@EqualsAndHashCodeabstract class SingleFieldPartitioning implements Partitioning {String[] fieldName;+ /** @return The field name of the partitioning. */public String[] fieldName() {return fieldName;}+ /**+ * Validates the partitioning columns.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the columns are invalid, this exception is thrown.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {validateFieldExistence(columns, fieldName);}+ /** @return The name of the partitioning strategy. */@Overridepublic String name() {return strategy().name().toLowerCase();}+ /** @return The arguments of the partitioning strategy. */@Overridepublic Expression[] arguments() {return new Expression[] {field(fieldName)};diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/RangePartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/RangePartitioningDTO.javaindex b71df1b6a2..e76fa20a07 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/RangePartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/RangePartitioningDTO.java@@ -11,8 +11,16 @@ import com.datastrato.gravitino.dto.rel.ColumnDTO;import com.datastrato.gravitino.rel.expressions.Expression;import lombok.EqualsAndHashCode;+/** Represents the range partitioning. */@EqualsAndHashCodepublic final class RangePartitioningDTO implements Partitioning {++ /**+ * Creates a new RangePartitioningDTO.+ *+ * @param fieldName The name of the field to partition.+ * @return The new RangePartitioningDTO.+ */public static RangePartitioningDTO of(String[] fieldName) {return new RangePartitioningDTO(fieldName);}@@ -23,38 +31,60 @@ public final class RangePartitioningDTO implements Partitioning {this.fieldName = fieldName;}+ /** @return The name of the field to partition. */public String[] fieldName() {return fieldName;}+ /** @return The name of the partitioning strategy. */@Overridepublic String name() {return strategy().name().toLowerCase();}+ /** @return The arguments of the partitioning. */@Overridepublic Expression[] arguments() {return new Expression[] {field(fieldName)};}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.RANGE;}+ /**+ * Validates the partitioning columns.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the columns are invalid, this exception is thrown.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {validateFieldExistence(columns, fieldName);}+ /** The builder for the RangePartitioningDTO. */public static class Builder {private String[] fieldName;+ /**+ * Set the field name for the builder.+ *+ * @param fieldName The name of the field to partition.+ * @return The builder.+ */public Builder withFieldName(String[] fieldName) {this.fieldName = fieldName;return this;}+ /**+ * Builds the RangePartitioningDTO.+ *+ * @return The new RangePartitioningDTO.+ */public RangePartitioningDTO build() {return new RangePartitioningDTO(fieldName);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/TruncatePartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/TruncatePartitioningDTO.javaindex 2c710d0fa4..6d8aca27ff 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/TruncatePartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/TruncatePartitioningDTO.java@@ -11,8 +11,17 @@ import com.datastrato.gravitino.dto.rel.ColumnDTO;import com.datastrato.gravitino.rel.expressions.Expression;import lombok.EqualsAndHashCode;+/** Represents the truncate partitioning. */@EqualsAndHashCodepublic final class TruncatePartitioningDTO implements Partitioning {++ /**+ * Constructs a truncate partitioning.+ *+ * @param width The width of the truncate partitioning.+ * @param fieldName The name of the field to partition.+ * @return The truncate partitioning.+ */public static TruncatePartitioningDTO of(int width, String[] fieldName) {return new TruncatePartitioningDTO(width, fieldName);}@@ -25,29 +34,40 @@ public final class TruncatePartitioningDTO implements Partitioning {this.fieldName = fieldName;}+ /** @return The width of the partitioning. */public int width() {return width;}+ /** @return The name of the field to partition. */public String[] fieldName() {return fieldName;}+ /** @return The name of the partitioning strategy. */@Overridepublic String name() {return strategy().name().toLowerCase();}+ /** @return The arguments of the partitioning. */@Overridepublic Expression[] arguments() {return truncate(width, fieldName).arguments();}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.TRUNCATE;}+ /**+ * Validates the partitioning columns.+ *+ * @param columns The columns to be validated.+ * @throws IllegalArgumentException If the columns are invalid, this exception is thrown.+ */@Overridepublic void validate(ColumnDTO[] columns) throws IllegalArgumentException {validateFieldExistence(columns, fieldName);diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/YearPartitioningDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/YearPartitioningDTO.javaindex 687ff3e98d..e0678a7d71 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/YearPartitioningDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitioning/YearPartitioningDTO.java@@ -7,7 +7,15 @@ package com.datastrato.gravitino.dto.rel.partitioning;import com.google.common.base.Preconditions;import org.apache.commons.lang3.ArrayUtils;+/** Represents the year partitioning. */public final class YearPartitioningDTO extends Partitioning.SingleFieldPartitioning {++ /**+ * Creates a new YearPartitioningDTO.+ *+ * @param fieldName The name of the field to partition.+ * @return The new YearPartitioningDTO.+ */public static YearPartitioningDTO of(String[] fieldName) {return new YearPartitioningDTO(fieldName);}@@ -18,6 +26,7 @@ public final class YearPartitioningDTO extends Partitioning.SingleFieldPartitionthis.fieldName = fieldName;}+ /** @return The strategy of the partitioning. */@Overridepublic Strategy strategy() {return Strategy.YEAR;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/IdentityPartitionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/IdentityPartitionDTO.javaindex 9e692dd30f..5fae831f70 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/IdentityPartitionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/IdentityPartitionDTO.java@@ -10,6 +10,7 @@ import java.util.Arrays;import java.util.Map;import java.util.Objects;+/** Data transfer object representing an identity partition. */public class IdentityPartitionDTO implements PartitionDTO, IdentityPartition {private final String name;@@ -17,6 +18,7 @@ public class IdentityPartitionDTO implements PartitionDTO, IdentityPartition {private final LiteralDTO[] values;private final Map<String, String> properties;+ /** @return A builder instance for {@link IdentityPartitionDTO}. */public static Builder builder() {return new Builder();}@@ -33,57 +35,92 @@ public class IdentityPartitionDTO implements PartitionDTO, IdentityPartition {this.properties = properties;}+ /** @return The name of the partition. */@Overridepublic String name() {return name;}+ /** @return The field names. */@Overridepublic String[][] fieldNames() {return fieldNames;}+ /** @return The values. */@Overridepublic LiteralDTO[] values() {return values;}+ /** @return The properties. */@Overridepublic Map<String, String> properties() {return properties;}+ /** @return The type of the partition. */@Overridepublic Type type() {return Type.IDENTITY;}+ /** Builder for {@link IdentityPartitionDTO}. */public static class Builder {private String name;private String[][] fieldNames;private LiteralDTO[] values;private Map<String, String> properties;+ /**+ * Set the name of the partition.+ *+ * @param name The name of the partition.+ * @return The builder.+ */public Builder withName(String name) {this.name = name;return this;}+ /**+ * Set the field names for the partition.+ *+ * @param fieldNames The field names.+ * @return The builder.+ */public Builder withFieldNames(String[][] fieldNames) {this.fieldNames = fieldNames;return this;}+ /**+ * Set the values for the partition.+ *+ * @param values The values.+ * @return The builder.+ */public Builder withValues(LiteralDTO[] values) {this.values = values;return this;}+ /**+ * Set the properties for the partition.+ *+ * @param properties The properties.+ * @return The builder.+ */public Builder withProperties(Map<String, String> properties) {this.properties = properties;return this;}+ /**+ * Build the partition.+ *+ * @return The partition.+ */public IdentityPartitionDTO build() {return new IdentityPartitionDTO(name, fieldNames, values, properties);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/ListPartitionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/ListPartitionDTO.javaindex ee9036caf9..aa1ff27c62 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/ListPartitionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/ListPartitionDTO.java@@ -10,12 +10,17 @@ import java.util.Arrays;import java.util.Map;import java.util.Objects;+/**+ * Represents a List Partition Data Transfer Object (DTO) that implements the ListPartition+ * interface.+ */public class ListPartitionDTO implements PartitionDTO, ListPartition {private final String name;private final LiteralDTO[][] lists;private final Map<String, String> properties;+ /** @return The builder for ListPartitionDTO. */public static Builder builder() {return new Builder();}@@ -30,46 +35,73 @@ public class ListPartitionDTO implements PartitionDTO, ListPartition {this.properties = properties;}+ /** @return The name of the partition. */@Overridepublic String name() {return name;}+ /** @return The lists of the partition. */@Overridepublic LiteralDTO[][] lists() {return lists;}+ /** @return The properties of the partition. */@Overridepublic Map<String, String> properties() {return properties;}- @Override+ /** @return The type of the partition. */public Type type() {return Type.LIST;}+ /** The builder for ListPartitionDTO. */public static class Builder {private String name;private LiteralDTO[][] lists;private Map<String, String> properties;+ /**+ * Set the name of the partition for the builder.+ *+ * @param name The name of the partition.+ * @return The builder.+ */public Builder withName(String name) {this.name = name;return this;}+ /**+ * Set the lists of the partition for the builder.+ *+ * @param lists The lists of the partition.+ * @return The builder.+ */public Builder withLists(LiteralDTO[][] lists) {this.lists = lists;return this;}+ /**+ * Set the properties of the partition for the builder.+ *+ * @param properties The properties of the partition.+ * @return The builder.+ */public Builder withProperties(Map<String, String> properties) {this.properties = properties;return this;}+ /**+ * Build the ListPartitionDTO.+ *+ * @return The ListPartitionDTO.+ */public ListPartitionDTO build() {return new ListPartitionDTO(name, lists, properties);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/PartitionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/PartitionDTO.javaindex dbde45990a..b97f79eac1 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/PartitionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/PartitionDTO.java@@ -9,15 +9,23 @@ import com.datastrato.gravitino.rel.partitions.Partition;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;import com.fasterxml.jackson.databind.annotation.JsonSerialize;+/** Represents a Partition Data Transfer Object (DTO) that implements the Partition interface. */@JsonSerialize(using = JsonUtils.PartitionDTOSerializer.class)@JsonDeserialize(using = JsonUtils.PartitionDTODeserializer.class)public interface PartitionDTO extends Partition {+ /** @return The type of the partition. */Type type();+ /** Type of the partition. */enum Type {+ /** The range partition type. */RANGE,++ /** The list partition type. */LIST,++ /** The identity partition type. */IDENTITY}}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/RangePartitionDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/RangePartitionDTO.javaindex b3738b9257..c45f78bee5 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/RangePartitionDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/rel/partitions/RangePartitionDTO.java@@ -9,6 +9,7 @@ import com.datastrato.gravitino.rel.partitions.RangePartition;import java.util.Map;import java.util.Objects;+/** Data transfer object representing a range partition. */public class RangePartitionDTO implements PartitionDTO, RangePartition {private final String name;@@ -16,6 +17,7 @@ public class RangePartitionDTO implements PartitionDTO, RangePartition {private final LiteralDTO upper;private final LiteralDTO lower;+ /** @return A builder instance for {@link RangePartitionDTO}. */public static Builder builder() {return new Builder();}@@ -32,21 +34,25 @@ public class RangePartitionDTO implements PartitionDTO, RangePartition {this.lower = lower;}+ /** @return The name of the partition. */@Overridepublic String name() {return name;}+ /** @return The upper bound. */@Overridepublic LiteralDTO upper() {return upper;}+ /** @return The lower bound. */@Overridepublic LiteralDTO lower() {return lower;}+ /** @return The properties. */@Overridepublic Map<String, String> properties() {return properties;@@ -72,37 +78,64 @@ public class RangePartitionDTO implements PartitionDTO, RangePartition {return Objects.hash(name, properties, upper, lower);}+ /** @return The type of the partition. */@Overridepublic Type type() {return Type.RANGE;}+ /** Builder for {@link RangePartitionDTO}. */public static class Builder {private String name;private Map<String, String> properties;private LiteralDTO upper;private LiteralDTO lower;+ /**+ * Set the name for the partition.+ *+ * @param name The name.+ * @return The builder.+ */public Builder withName(String name) {this.name = name;return this;}+ /**+ * Set the properties for the partition.+ *+ * @param properties The properties.+ * @return The builder.+ */public Builder withProperties(Map<String, String> properties) {this.properties = properties;return this;}+ /**+ * Set the upper bound for the partition.+ *+ * @param upper The upper bound.+ * @return The builder.+ */public Builder withUpper(LiteralDTO upper) {this.upper = upper;return this;}+ /**+ * Set the lower bound for the partition.+ *+ * @param lower The lower bound.+ * @return The builder.+ */public Builder withLower(LiteralDTO lower) {this.lower = lower;return this;}+ /** @return The range partition instance. */public RangePartitionDTO build() {return new RangePartitionDTO(name, properties, upper, lower);}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetCreateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetCreateRequest.javaindex 221a6256f9..3e914830b2 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetCreateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetCreateRequest.java@@ -18,6 +18,7 @@ import lombok.NoArgsConstructor;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a request to create a fileset. */@Getter@EqualsAndHashCode@ToString@@ -45,6 +46,11 @@ public class FilesetCreateRequest implements RESTRequest {@JsonProperty("properties")private Map<String, String> properties;+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException if the request is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdateRequest.javaindex 850935227f..11d6c69914 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdateRequest.java@@ -18,6 +18,7 @@ import lombok.NoArgsConstructor;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Request to update a fileset. */@JsonIgnoreProperties(ignoreUnknown = true)@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)@JsonSubTypes({@@ -33,8 +34,15 @@ import org.apache.commons.lang3.StringUtils;name = "removeProperty")})public interface FilesetUpdateRequest extends RESTRequest {++ /**+ * Returns the fileset change.+ *+ * @return the fileset change.+ */FilesetChange filesetChange();+ /** The fileset update request for renaming a fileset. */@EqualsAndHashCode@NoArgsConstructor(force = true)@AllArgsConstructor@@ -45,11 +53,21 @@ public interface FilesetUpdateRequest extends RESTRequest {@JsonProperty("newName")private final String newName;+ /**+ * Returns the fileset change.+ *+ * @return the fileset change.+ */@Overridepublic FilesetChange filesetChange() {return FilesetChange.rename(newName);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException if the request is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -57,6 +75,7 @@ public interface FilesetUpdateRequest extends RESTRequest {}}+ /** The fileset update request for updating the comment of a fileset. */@EqualsAndHashCode@NoArgsConstructor(force = true)@AllArgsConstructor@@ -67,11 +86,17 @@ public interface FilesetUpdateRequest extends RESTRequest {@JsonProperty("newComment")private final String newComment;+ /** @return The fileset change. */@Overridepublic FilesetChange filesetChange() {return FilesetChange.updateComment(newComment);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException if the request is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -80,6 +105,7 @@ public interface FilesetUpdateRequest extends RESTRequest {}}+ /** The fileset update request for setting the properties of a fileset. */@EqualsAndHashCode@NoArgsConstructor(force = true)@AllArgsConstructor@@ -94,11 +120,16 @@ public interface FilesetUpdateRequest extends RESTRequest {@JsonProperty("value")private final String value;- @Override+ /** @return The fileset change. */public FilesetChange filesetChange() {return FilesetChange.setProperty(property, value);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException if the request is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -107,6 +138,7 @@ public interface FilesetUpdateRequest extends RESTRequest {}}+ /** The fileset update request for removing the properties of a fileset. */@EqualsAndHashCode@NoArgsConstructor(force = true)@AllArgsConstructor@@ -117,11 +149,17 @@ public interface FilesetUpdateRequest extends RESTRequest {@JsonProperty("property")private final String property;+ /** @return The fileset change. */@Overridepublic FilesetChange filesetChange() {return FilesetChange.removeProperty(property);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException if the request is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdatesRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdatesRequest.javaindex 8a283ad15e..bcb578ee6d 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdatesRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/FilesetUpdatesRequest.java@@ -14,6 +14,7 @@ import lombok.Getter;import lombok.NoArgsConstructor;import lombok.ToString;+/** Request to represent updates to a fileset. */@Getter@EqualsAndHashCode@NoArgsConstructor(force = true)diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/MetalakeUpdateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/MetalakeUpdateRequest.javaindex 619990af57..0041e25fe3 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/MetalakeUpdateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/MetalakeUpdateRequest.java@@ -40,6 +40,7 @@ public interface MetalakeUpdateRequest extends RESTRequest {*/MetalakeChange metalakeChange();+ /** Represents a request to rename a Metalake. */@EqualsAndHashCode@ToStringclass RenameMetalakeRequest implements MetalakeUpdateRequest {@@ -79,6 +80,7 @@ public interface MetalakeUpdateRequest extends RESTRequest {}}+ /** Represents a request to update the comment on a Metalake. */@EqualsAndHashCode@ToStringclass UpdateMetalakeCommentRequest implements MetalakeUpdateRequest {@@ -119,6 +121,7 @@ public interface MetalakeUpdateRequest extends RESTRequest {}}+ /** Represents a request to set a property on a Metalake. */@EqualsAndHashCode@ToStringclass SetMetalakePropertyRequest implements MetalakeUpdateRequest {@@ -165,6 +168,7 @@ public interface MetalakeUpdateRequest extends RESTRequest {}}+ /** Represents a request to remove a property from a Metalake. */@EqualsAndHashCode@ToStringclass RemoveMetalakePropertyRequest implements MetalakeUpdateRequest {diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaCreateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaCreateRequest.javaindex 0d936d0708..a7cc10c533 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaCreateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaCreateRequest.java@@ -14,6 +14,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a request to create a schema. */@Getter@EqualsAndHashCode@ToString@@ -30,16 +31,29 @@ public class SchemaCreateRequest implements RESTRequest {@JsonProperty("properties")private final Map<String, String> properties;+ /** Default constructor for Jackson deserialization. */public SchemaCreateRequest() {this(null, null, null);}+ /**+ * Creates a new SchemaCreateRequest.+ *+ * @param name The name of the schema.+ * @param comment The comment of the schema.+ * @param properties The properties of the schema.+ */public SchemaCreateRequest(String name, String comment, Map<String, String> properties) {this.name = name;this.comment = comment;this.properties = properties;}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdateRequest.javaindex 045f3b3acb..e156350d07 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdateRequest.java@@ -16,6 +16,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a request to update a schema. */@JsonIgnoreProperties(ignoreUnknown = true)@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)@JsonSubTypes({@@ -28,8 +29,14 @@ import org.apache.commons.lang3.StringUtils;})public interface SchemaUpdateRequest extends RESTRequest {+ /**+ * The schema change that is requested.+ *+ * @return An instance of SchemaChange.+ */SchemaChange schemaChange();+ /** Represents a request to set a property of a schema. */@EqualsAndHashCode@ToStringclass SetSchemaPropertyRequest implements SchemaUpdateRequest {@@ -42,15 +49,27 @@ public interface SchemaUpdateRequest extends RESTRequest {@JsonProperty("value")private final String value;+ /**+ * Creates a new SetSchemaPropertyRequest.+ *+ * @param property The property to set.+ * @param value The value to set.+ */public SetSchemaPropertyRequest(String property, String value) {this.property = property;this.value = value;}+ /** Default constructor for Jackson deserialization. */public SetSchemaPropertyRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -59,12 +78,18 @@ public interface SchemaUpdateRequest extends RESTRequest {StringUtils.isNotBlank(value), "\"value\" field is required and cannot be empty");}+ /**+ * Returns the schema change.+ *+ * @return An instance of SchemaChange.+ */@Overridepublic SchemaChange schemaChange() {return SchemaChange.setProperty(property, value);}}+ /** Represents a request to remove a property of a schema. */@EqualsAndHashCode@ToStringclass RemoveSchemaPropertyRequest implements SchemaUpdateRequest {@@ -73,20 +98,36 @@ public interface SchemaUpdateRequest extends RESTRequest {@JsonProperty("property")private final String property;+ /**+ * Creates a new RemoveSchemaPropertyRequest.+ *+ * @param property The property to remove.+ */public RemoveSchemaPropertyRequest(String property) {this.property = property;}+ /** Default constructor for Jackson deserialization. */public RemoveSchemaPropertyRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");}+ /**+ * Returns the schema change.+ *+ * @return An instance of SchemaChange.+ */@Overridepublic SchemaChange schemaChange() {return SchemaChange.removeProperty(property);diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdatesRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdatesRequest.javaindex 474c48f12f..834741a343 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdatesRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/SchemaUpdatesRequest.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request to update a schema. */@Getter@EqualsAndHashCode@ToString@@ -19,14 +20,25 @@ public class SchemaUpdatesRequest implements RESTRequest {@JsonProperty("updates")private final List<SchemaUpdateRequest> updates;+ /**+ * Creates a new SchemaUpdatesRequest.+ *+ * @param updates The updates to apply to the schema.+ */public SchemaUpdatesRequest(List<SchemaUpdateRequest> updates) {this.updates = updates;}+ /** This is the constructor that is used by Jackson deserializer */public SchemaUpdatesRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {updates.forEach(RESTRequest::validate);diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableCreateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableCreateRequest.javaindex e7636a592f..67427e369c 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableCreateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableCreateRequest.java@@ -25,6 +25,7 @@ import lombok.ToString;import lombok.extern.jackson.Jacksonized;import org.apache.commons.lang3.StringUtils;+/** Represents a request to create a table. */@Getter@EqualsAndHashCode@ToString@@ -62,10 +63,23 @@ public class TableCreateRequest implements RESTRequest {@JsonProperty("indexes")private final IndexDTO[] indexes;+ /** Default constructor for Jackson deserialization. */public TableCreateRequest() {this(null, null, null, null, null, null, null, null);}+ /**+ * Creates a new TableCreateRequest.+ *+ * @param name The name of the table.+ * @param comment The comment of the table.+ * @param columns The columns of the table.+ * @param properties The properties of the table.+ * @param sortOrders The sort orders of the table.+ * @param distribution The distribution of the table.+ * @param partitioning The partitioning of the table.+ * @param indexes The indexes of the table.+ */public TableCreateRequest(String name,@Nullable String comment,@@ -85,6 +99,11 @@ public class TableCreateRequest implements RESTRequest {this.indexes = indexes;}+ /**+ * Validates the {@link TableCreateRequest} request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.javaindex 156e6776a6..a346065ec7 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdateRequest.java@@ -22,6 +22,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a request to update a table. */@JsonIgnoreProperties(ignoreUnknown = true)@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)@JsonSubTypes({@@ -57,8 +58,14 @@ import org.apache.commons.lang3.StringUtils;})public interface TableUpdateRequest extends RESTRequest {+ /**+ * The table change that is requested.+ *+ * @return An instance of TableChange.+ */TableChange tableChange();+ /** Represents a request to rename a table. */@EqualsAndHashCode@ToStringclass RenameTableRequest implements TableUpdateRequest {@@ -67,26 +74,43 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("newName")private final String newName;+ /**+ * Constructor for RenameTableRequest.+ *+ * @param newName the new name of the table+ */public RenameTableRequest(String newName) {this.newName = newName;}+ /** Default constructor for Jackson deserialization. */public RenameTableRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(StringUtils.isNotBlank(newName), "\"newName\" field is required and cannot be empty");}+ /**+ * Returns the table change.+ *+ * @return An instance of TableChange.+ */@Overridepublic TableChange tableChange() {return TableChange.rename(newName);}}+ /** Represents a request to update the comment of a table. */@EqualsAndHashCode@ToStringclass UpdateTableCommentRequest implements TableUpdateRequest {@@ -95,14 +119,25 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("newComment")private final String newComment;+ /**+ * Constructor for UpdateTableCommentRequest.+ *+ * @param newComment the new comment of the table+ */public UpdateTableCommentRequest(String newComment) {this.newComment = newComment;}+ /** Default constructor for Jackson deserialization. */public UpdateTableCommentRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -110,12 +145,18 @@ public interface TableUpdateRequest extends RESTRequest {"\"newComment\" field is required and cannot be empty");}+ /**+ * Returns the table change.+ *+ * @return An instance of TableChange.+ */@Overridepublic TableChange tableChange() {return TableChange.updateComment(newComment);}}+ /** Represents a request to set a property of a table. */@EqualsAndHashCode@ToStringclass SetTablePropertyRequest implements TableUpdateRequest {@@ -128,15 +169,27 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("value")private final String value;+ /**+ * Constructor for SetTablePropertyRequest.+ *+ * @param property the property to set+ * @param value the value to set+ */public SetTablePropertyRequest(String property, String value) {this.property = property;this.value = value;}+ /** Default constructor for Jackson deserialization. */public SetTablePropertyRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -144,12 +197,18 @@ public interface TableUpdateRequest extends RESTRequest {Preconditions.checkArgument(value != null, "\"value\" field is required and cannot be null");}+ /**+ * Returns the table change.+ *+ * @return An instance of TableChange.+ */@Overridepublic TableChange tableChange() {return TableChange.setProperty(property, value);}}+ /** Represents a request to remove a property of a table. */@EqualsAndHashCode@ToStringclass RemoveTablePropertyRequest implements TableUpdateRequest {@@ -158,26 +217,39 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("property")private final String property;+ /**+ * Constructor for RemoveTablePropertyRequest.+ *+ * @param property the property to remove+ */public RemoveTablePropertyRequest(String property) {this.property = property;}+ /** Default constructor for Jackson deserialization. */public RemoveTablePropertyRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(StringUtils.isNotBlank(property), "\"property\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.removeProperty(property);}}+ /** Represents a request to add a column to a table. */@EqualsAndHashCode@ToStringclass AddTableColumnRequest implements TableUpdateRequest {@@ -208,7 +280,7 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty(value = "nullable", defaultValue = "true")private final boolean nullable;- // For Jackson deserialization+ /** Default constructor for Jackson deserialization. */public AddTableColumnRequest() {this(null, null, null, null, true);}@@ -259,6 +331,11 @@ public interface TableUpdateRequest extends RESTRequest {this(fieldName, dataType, comment, TableChange.ColumnPosition.defaultPos());}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -270,12 +347,14 @@ public interface TableUpdateRequest extends RESTRequest {dataType != null, "\"type\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.addColumn(fieldName, dataType, comment, position, nullable);}}+ /** Represents a request to rename a column of a table. */@EqualsAndHashCode@ToStringclass RenameTableColumnRequest implements TableUpdateRequest {@@ -288,15 +367,27 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("newFieldName")private final String newFieldName;+ /**+ * Constructor for RenameTableColumnRequest.+ *+ * @param oldFieldName the old field name to rename+ * @param newFieldName the new field name+ */public RenameTableColumnRequest(String[] oldFieldName, String newFieldName) {this.oldFieldName = oldFieldName;this.newFieldName = newFieldName;}+ /** Default constructor for Jackson deserialization. */public RenameTableColumnRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -309,12 +400,14 @@ public interface TableUpdateRequest extends RESTRequest {"\"newFieldName\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.renameColumn(oldFieldName, newFieldName);}}+ /** Represents a request to update the type of a column of a table. */@EqualsAndHashCode@ToStringclass UpdateTableColumnTypeRequest implements TableUpdateRequest {@@ -329,15 +422,27 @@ public interface TableUpdateRequest extends RESTRequest {@JsonDeserialize(using = JsonUtils.TypeDeserializer.class)private final Type newType;+ /**+ * Constructor for UpdateTableColumnTypeRequest.+ *+ * @param fieldName the field name to update+ * @param newType the new type of the field+ */public UpdateTableColumnTypeRequest(String[] fieldName, Type newType) {this.fieldName = fieldName;this.newType = newType;}+ /** Default constructor for Jackson deserialization. */public UpdateTableColumnTypeRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -349,12 +454,14 @@ public interface TableUpdateRequest extends RESTRequest {newType != null, "\"newType\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.updateColumnType(fieldName, newType);}}+ /** Represents a request to update the comment of a column of a table. */@EqualsAndHashCode@ToStringclass UpdateTableColumnCommentRequest implements TableUpdateRequest {@@ -367,15 +474,27 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("newComment")private final String newComment;+ /**+ * Constructor for UpdateTableColumnCommentRequest.+ *+ * @param fieldName the field name to update+ * @param newComment the new comment of the field+ */public UpdateTableColumnCommentRequest(String[] fieldName, String newComment) {this.fieldName = fieldName;this.newComment = newComment;}+ /** Default constructor for Jackson deserialization. */public UpdateTableColumnCommentRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -388,12 +507,14 @@ public interface TableUpdateRequest extends RESTRequest {"\"newComment\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.updateColumnComment(fieldName, newComment);}}+ /** Represents a request to update the position of a column of a table. */@EqualsAndHashCode@ToStringclass UpdateTableColumnPositionRequest implements TableUpdateRequest {@@ -408,16 +529,28 @@ public interface TableUpdateRequest extends RESTRequest {@JsonDeserialize(using = JsonUtils.ColumnPositionDeserializer.class)private final TableChange.ColumnPosition newPosition;+ /**+ * Constructor for UpdateTableColumnPositionRequest.+ *+ * @param fieldName the field name to update+ * @param newPosition the new position of the field+ */public UpdateTableColumnPositionRequest(String[] fieldName, TableChange.ColumnPosition newPosition) {this.fieldName = fieldName;this.newPosition = newPosition;}+ /** Default constructor for Jackson deserialization. */public UpdateTableColumnPositionRequest() {this(null, null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -429,12 +562,14 @@ public interface TableUpdateRequest extends RESTRequest {newPosition != null, "\"newPosition\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.updateColumnPosition(fieldName, newPosition);}}+ /** Represents a request to update the nullability of a column of a table. */@EqualsAndHashCode@ToStringclass UpdateTableColumnNullabilityRequest implements TableUpdateRequest {@@ -447,21 +582,37 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("nullable")private final boolean nullable;+ /**+ * Constructor for UpdateTableColumnNullabilityRequest.+ *+ * @param fieldName the field name to update+ * @param nullable the new nullability of the field+ */public UpdateTableColumnNullabilityRequest(String[] fieldName, boolean nullable) {this.fieldName = fieldName;this.nullable = nullable;}- // For Jackson deserialization+ /** Default constructor for Jackson deserialization. */public UpdateTableColumnNullabilityRequest() {this(null, true);}+ /**+ * Validates the request.+ *+ * @return An instance of TableChange.+ */@Overridepublic TableChange tableChange() {return TableChange.updateColumnNullability(fieldName, nullable);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -472,6 +623,7 @@ public interface TableUpdateRequest extends RESTRequest {}}+ /** Represents a request to delete a column from a table. */@EqualsAndHashCode@ToStringclass DeleteTableColumnRequest implements TableUpdateRequest {@@ -484,15 +636,27 @@ public interface TableUpdateRequest extends RESTRequest {@JsonProperty("ifExists")private final boolean ifExists;+ /**+ * Constructor for DeleteTableColumnRequest.+ *+ * @param fieldName the field name to delete+ * @param ifExists whether to delete the column if it exists+ */public DeleteTableColumnRequest(String[] fieldName, boolean ifExists) {this.fieldName = fieldName;this.ifExists = ifExists;}+ /** Default constructor for Jackson deserialization. */public DeleteTableColumnRequest() {this(null, false);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -502,6 +666,7 @@ public interface TableUpdateRequest extends RESTRequest {"\"fieldName\" field is required and cannot be empty");}+ /** @return An instance of TableChange. */@Overridepublic TableChange tableChange() {return TableChange.deleteColumn(fieldName, ifExists);diff --git a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdatesRequest.java b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdatesRequest.javaindex 6b1f83616d..6125f8471e 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdatesRequest.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/requests/TableUpdatesRequest.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request to update a table. */@Getter@EqualsAndHashCode@ToString@@ -19,14 +20,25 @@ public class TableUpdatesRequest implements RESTRequest {@JsonProperty("updates")private final List<TableUpdateRequest> updates;+ /**+ * Creates a new TableUpdatesRequest.+ *+ * @param updates The updates to apply to the table.+ */public TableUpdatesRequest(List<TableUpdateRequest> updates) {this.updates = updates;}+ /** This is the constructor that is used by Jackson deserializer */public TableUpdatesRequest() {this(null);}+ /**+ * Validates the request.+ *+ * @throws IllegalArgumentException If the request is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {updates.forEach(RESTRequest::validate);diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorConstants.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorConstants.javaindex ddbd4d47c6..693cb67b4f 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorConstants.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorConstants.java@@ -6,12 +6,28 @@ package com.datastrato.gravitino.dto.responses;/** Constants representing error codes for responses. */public class ErrorConstants {++ /** Error codes for REST responses error. */public static final int REST_ERROR_CODE = 1000;++ /** Error codes for illegal arguments. */public static final int ILLEGAL_ARGUMENTS_CODE = 1001;++ /** Error codes for internal errors. */public static final int INTERNAL_ERROR_CODE = 1002;++ /** Error codes for not found. */public static final int NOT_FOUND_CODE = 1003;++ /** Error codes for already exists. */public static final int ALREADY_EXISTS_CODE = 1004;++ /** Error codes for non empty. */public static final int NON_EMPTY_CODE = 1005;++ /** Error codes for unsupported operation. */public static final int UNSUPPORTED_OPERATION_CODE = 1006;++ /** Error codes for invalid state. */public static final int UNKNOWN_ERROR_CODE = 1100;}diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorResponse.javaindex 15b8564c11..4a07982aae 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/ErrorResponse.java@@ -15,6 +15,7 @@ import javax.annotation.Nullable;import lombok.EqualsAndHashCode;import lombok.Getter;+/** Represents an error response. */@Getter@EqualsAndHashCode(callSuper = true)public class ErrorResponse extends BaseResponse {@@ -43,6 +44,7 @@ public class ErrorResponse extends BaseResponse {this.stack = null;}+ /** Validates the error response. */@Overridepublic void validate() {super.validate();@@ -73,15 +75,34 @@ public class ErrorResponse extends BaseResponse {return sb.toString();}+ /**+ * Creates a new rest error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse restError(String message) {return new ErrorResponse(ErrorConstants.REST_ERROR_CODE, RESTException.class.getSimpleName(), message, null);}+ /**+ * Create a new illegal arguments error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse illegalArguments(String message) {return illegalArguments(message, null);}+ /**+ * Create a new illegal arguments error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse illegalArguments(String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.ILLEGAL_ARGUMENTS_CODE,@@ -90,19 +111,47 @@ public class ErrorResponse extends BaseResponse {getStackTrace(throwable));}+ /**+ * Create a new not found error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse notFound(String type, String message) {return notFound(type, message, null);}+ /**+ * Create a new not found error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse notFound(String type, String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.NOT_FOUND_CODE, type, message, getStackTrace(throwable));}+ /**+ * Create a new internal error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse internalError(String message) {return internalError(message, null);}+ /**+ * Create a new internal error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse internalError(String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.INTERNAL_ERROR_CODE,@@ -111,37 +160,94 @@ public class ErrorResponse extends BaseResponse {getStackTrace(throwable));}+ /**+ * Create a new already exists error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse alreadyExists(String type, String message) {return alreadyExists(type, message, null);}+ /**+ * Create a new already exists error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse alreadyExists(String type, String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.ALREADY_EXISTS_CODE, type, message, getStackTrace(throwable));}+ /**+ * Create a new non empty error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse nonEmpty(String type, String message) {return nonEmpty(type, message, null);}+ /**+ * Create a new non empty error instance of {@link ErrorResponse}.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse nonEmpty(String type, String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.NON_EMPTY_CODE, type, message, getStackTrace(throwable));}+ /**+ * Create a new unknown error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse unknownError(String message) {return new ErrorResponse(ErrorConstants.UNKNOWN_ERROR_CODE, RuntimeException.class.getSimpleName(), message, null);}+ /**+ * Create a new unknown error instance of {@link ErrorResponse}.+ *+ * @param code The code of the error.+ * @param type The type of the error.+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse oauthError(int code, String type, String message) {return new ErrorResponse(code, type, message, null);}+ /**+ * Create a new unsupported operation error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @return The new instance.+ */public static ErrorResponse unsupportedOperation(String message) {return unsupportedOperation(message, null);}+ /**+ * Create a new unsupported operation error instance of {@link ErrorResponse}.+ *+ * @param message The message of the error.+ * @param throwable The throwable that caused the error.+ * @return The new instance.+ */public static ErrorResponse unsupportedOperation(String message, Throwable throwable) {return new ErrorResponse(ErrorConstants.UNSUPPORTED_OPERATION_CODE,diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/FilesetResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/FilesetResponse.javaindex 200a5dd64d..a6b8910ae6 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/FilesetResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/FilesetResponse.java@@ -12,6 +12,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Response for fileset creation. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -20,16 +21,27 @@ public class FilesetResponse extends BaseResponse {@JsonProperty("fileset")private final FilesetDTO fileset;+ /** Constructor for FilesetResponse. */public FilesetResponse() {super(0);this.fileset = null;}+ /**+ * Constructor for FilesetResponse.+ *+ * @param fileset the fileset DTO object.+ */public FilesetResponse(FilesetDTO fileset) {super(0);this.fileset = fileset;}+ /**+ * Validates the response.+ *+ * @throws IllegalArgumentException if the response is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2ErrorResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2ErrorResponse.javaindex 53381cf06a..bb26a930f4 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2ErrorResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2ErrorResponse.java@@ -12,6 +12,7 @@ import javax.annotation.Nullable;import lombok.EqualsAndHashCode;import lombok.Getter;+/** Represents the response of an OAuth2 error. */@Getter@EqualsAndHashCodepublic class OAuth2ErrorResponse implements RESTResponse {@@ -22,14 +23,25 @@ public class OAuth2ErrorResponse implements RESTResponse {@JsonProperty("error_description")private String message;+ /**+ * Creates a new OAuth2ErrorResponse.+ *+ * @param type The type of the error.+ * @param message The message of the error.+ */public OAuth2ErrorResponse(String type, String message) {this.type = type;this.message = message;}- // This is the constructor that is used by Jackson deserializer+ /** This is the constructor that is used by Jackson deserializer */public OAuth2ErrorResponse() {}+ /**+ * Validates the OAuth2ErrorResponse.+ *+ * @throws IllegalArgumentException if the OAuth2ErrorResponse is invalid.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(type != null, "OAuthErrorResponse should contain type");diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2TokenResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2TokenResponse.javaindex f500540fa3..8df353365f 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2TokenResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/OAuth2TokenResponse.java@@ -29,6 +29,8 @@ import org.apache.commons.lang3.StringUtils;// Referred from Apache Iceberg's OAuthTokenResponse implementation// core/src/main/java/org/apache/iceberg/rest/auth/responses/OAuthTokenResponse.java++/** Represents the response of an OAuth2 token request. */@Getter@EqualsAndHashCode(callSuper = true)@ToString@@ -53,6 +55,16 @@ public class OAuth2TokenResponse extends BaseResponse {@JsonProperty("refresh_token")private final String refreshToken;+ /**+ * Creates a new OAuth2TokenResponse.+ *+ * @param accessToken The access token.+ * @param issuedTokenType The issued token type.+ * @param tokenType The token type.+ * @param expiresIn The expiration time of the token in seconds.+ * @param scope The scope of the token.+ * @param refreshToken The refresh token.+ */public OAuth2TokenResponse(String accessToken,String issuedTokenType,@@ -68,7 +80,9 @@ public class OAuth2TokenResponse extends BaseResponse {this.refreshToken = refreshToken;}- // This is the constructor that is used by Jackson deserializer+ /**+ * Creates a new OAuth2TokenResponse. This is the constructor that is used by Jackson deserializer+ */public OAuth2TokenResponse() {super();this.accessToken = null;@@ -79,6 +93,11 @@ public class OAuth2TokenResponse extends BaseResponse {this.refreshToken = null;}+ /**+ * Validates the response.+ *+ * @throws IllegalArgumentException If the response is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(StringUtils.isNotBlank(accessToken), "Invalid access token: null");diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionListResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionListResponse.javaindex abe94202a6..13236550fe 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionListResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionListResponse.java@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a response for a list of partitions. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -18,12 +19,20 @@ public class PartitionListResponse extends BaseResponse {@JsonProperty("partitions")private final PartitionDTO[] partitions;+ /**+ * Creates a new PartitionListResponse.+ *+ * @param partitions The list of partitions.+ */public PartitionListResponse(PartitionDTO[] partitions) {super(0);this.partitions = partitions;}- // This is the constructor that is used by Jackson deserializer+ /**+ * This is the constructor that is used by Jackson deserializer to create an instance of+ * PartitionListResponse.+ */public PartitionListResponse() {super();this.partitions = null;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionResponse.javaindex bcbf5e3239..4578fd2972 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionResponse.java@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a response for a partition. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -18,12 +19,17 @@ public class PartitionResponse extends BaseResponse {@JsonProperty("partition")private final PartitionDTO partition;+ /**+ * Creates a new PartitionResponse.+ *+ * @param partition The partition.+ */public PartitionResponse(PartitionDTO partition) {super(0);this.partition = partition;}- // This is the constructor that is used by Jackson deserializer+ /** This is the constructor that is used by Jackson deserializer */public PartitionResponse() {super();this.partition = null;diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/SchemaResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/SchemaResponse.javaindex 6b5d421942..e4819623aa 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/SchemaResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/SchemaResponse.java@@ -12,6 +12,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a response for a schema. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -20,17 +21,27 @@ public class SchemaResponse extends BaseResponse {@JsonProperty("schema")private final SchemaDTO schema;+ /**+ * Creates a new SchemaResponse.+ *+ * @param schema The schema DTO object.+ */public SchemaResponse(SchemaDTO schema) {super(0);this.schema = schema;}- // This is the constructor that is used by Jackson deserializer+ /** This is the constructor that is used by Jackson deserializer */public SchemaResponse() {super();this.schema = null;}+ /**+ * Validates the response.+ *+ * @throws IllegalArgumentException If the response is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/gravitino/dto/responses/TableResponse.java b/common/src/main/java/com/datastrato/gravitino/dto/responses/TableResponse.javaindex a843e102b8..74e208138a 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/responses/TableResponse.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/responses/TableResponse.java@@ -12,6 +12,7 @@ import lombok.Getter;import lombok.ToString;import org.apache.commons.lang3.StringUtils;+/** Represents a response for a table. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -20,17 +21,27 @@ public class TableResponse extends BaseResponse {@JsonProperty("table")private final TableDTO table;+ /**+ * Creates a new TableResponse.+ *+ * @param table The table DTO object.+ */public TableResponse(TableDTO table) {super(0);this.table = table;}- // This is the constructor that is used by Jackson deserializer+ /** This is the constructor that is used by Jackson deserializer */public TableResponse() {super();this.table = null;}+ /**+ * Validates the response.+ *+ * @throws IllegalArgumentException If the response is invalid, this exception is thrown.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/gravitino/dto/util/DTOConverters.java b/common/src/main/java/com/datastrato/gravitino/dto/util/DTOConverters.javaindex 7aba04e33a..8f0ea5e072 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/util/DTOConverters.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/util/DTOConverters.java@@ -67,10 +67,17 @@ import com.datastrato.gravitino.rel.types.Types;import java.util.Arrays;import org.apache.commons.lang3.ArrayUtils;+/** Utility class for converting between DTOs and domain objects. */public class DTOConverters {private DTOConverters() {}+ /**+ * Converts a {@link Audit} to a {@link AuditDTO}.+ *+ * @param audit The audit.+ * @return The audit DTO.+ */public static AuditDTO toDTO(Audit audit) {return AuditDTO.builder().withCreator(audit.creator())@@ -80,6 +87,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a {@link Metalake} to a {@link MetalakeDTO}.+ *+ * @param metalake The metalake.+ * @return The metalake DTO.+ */public static MetalakeDTO toDTO(Metalake metalake) {return new MetalakeDTO.Builder().withName(metalake.name())@@ -89,6 +102,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a {@link Partition} to a {@link PartitionDTO}.+ *+ * @param partition The partition.+ * @return The partition DTO.+ */public static PartitionDTO toDTO(Partition partition) {if (partition instanceof RangePartition) {RangePartition rangePartition = (RangePartition) partition;@@ -128,6 +147,12 @@ public class DTOConverters {}}+ /**+ * Converts a {@link Catalog} to a {@link CatalogDTO}.+ *+ * @param catalog The catalog.+ * @return The catalog DTO.+ */public static CatalogDTO toDTO(Catalog catalog) {return new CatalogDTO.Builder().withName(catalog.name())@@ -139,6 +164,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a {@link Schema} to a {@link SchemaDTO}.+ *+ * @param schema The schema.+ * @return The schema DTO.+ */public static SchemaDTO toDTO(Schema schema) {return new SchemaDTO.Builder().withName(schema.name())@@ -148,6 +179,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a {@link Column} to a {@link ColumnDTO}.+ *+ * @param column The column.+ * @return The column DTO.+ */public static ColumnDTO toDTO(Column column) {return new ColumnDTO.Builder().withName(column.name())@@ -163,6 +200,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a table implementation to a {@link TableDTO}.+ *+ * @param table The table implementation.+ * @return The table DTO.+ */public static TableDTO toDTO(Table table) {return new TableDTO.Builder().withName(table.name())@@ -178,6 +221,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a Distribution implementation to a DistributionDTO.+ *+ * @param distribution The distribution implementation.+ * @return The distribution DTO.+ */public static DistributionDTO toDTO(Distribution distribution) {if (Distributions.NONE.equals(distribution) || null == distribution) {return DistributionDTO.NONE;@@ -197,6 +246,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a SortOrder implementation to a SortOrderDTO.+ *+ * @param sortOrder The sort order implementation.+ * @return The sort order DTO.+ */public static SortOrderDTO toDTO(SortOrder sortOrder) {if (sortOrder instanceof SortOrderDTO) {return (SortOrderDTO) sortOrder;@@ -208,6 +263,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a Transform implementation to a Partitioning DTO.+ *+ * @param transform The transform implementation.+ * @return The partitioning DTO.+ */public static Partitioning toDTO(Transform transform) {if (transform instanceof Partitioning) {return (Partitioning) transform;@@ -248,6 +309,12 @@ public class DTOConverters {}}+ /**+ * Converts an index implementation to an IndexDTO.+ *+ * @param index The index implementation.+ * @return The index DTO.+ */public static IndexDTO toDTO(Index index) {if (index instanceof IndexDTO) {return (IndexDTO) index;@@ -259,6 +326,12 @@ public class DTOConverters {.build();}+ /**+ * Converts a Expression to an FunctionArg DTO.+ *+ * @param expression The expression to be converted.+ * @return The expression DTO.+ */public static FunctionArg toFunctionArg(Expression expression) {if (expression instanceof FunctionArg) {return (FunctionArg) expression;@@ -293,6 +366,12 @@ public class DTOConverters {}}+ /**+ * Converts an array of Expressions to an array of FunctionArg DTOs.+ *+ * @param expressions The expressions to be converted.+ * @return The array of FunctionArg DTOs.+ */public static FunctionArg[] toFunctionArg(Expression[] expressions) {if (ArrayUtils.isEmpty(expressions)) {return FunctionArg.EMPTY_ARGS;@@ -300,6 +379,12 @@ public class DTOConverters {return Arrays.stream(expressions).map(DTOConverters::toFunctionArg).toArray(FunctionArg[]::new);}+ /**+ * Converts a Fileset to a FilesetDTO.+ *+ * @param fileset The fileset to be converted.+ * @return The fileset DTO.+ */public static FilesetDTO toDTO(Fileset fileset) {return FilesetDTO.builder().name(fileset.name())@@ -311,6 +396,12 @@ public class DTOConverters {.build();}+ /**+ * Converts an array of Columns to an array of ColumnDTOs.+ *+ * @param columns The columns to be converted.+ * @return The array of ColumnDTOs.+ */public static ColumnDTO[] toDTOs(Column[] columns) {if (ArrayUtils.isEmpty(columns)) {return new ColumnDTO[0];@@ -318,6 +409,12 @@ public class DTOConverters {return Arrays.stream(columns).map(DTOConverters::toDTO).toArray(ColumnDTO[]::new);}+ /**+ * Converts an array of SortOrders to an array of SortOrderDTOs.+ *+ * @param sortOrders The sort orders to be converted.+ * @return The array of SortOrderDTOs.+ */public static SortOrderDTO[] toDTOs(SortOrder[] sortOrders) {if (ArrayUtils.isEmpty(sortOrders)) {return new SortOrderDTO[0];@@ -325,6 +422,12 @@ public class DTOConverters {return Arrays.stream(sortOrders).map(DTOConverters::toDTO).toArray(SortOrderDTO[]::new);}+ /**+ * Converts an array of Transforms to an array of Partitioning DTOs.+ *+ * @param transforms The transforms to be converted.+ * @return The array of Partitioning DTOs.+ */public static Partitioning[] toDTOs(Transform[] transforms) {if (ArrayUtils.isEmpty(transforms)) {return new Partitioning[0];@@ -332,6 +435,12 @@ public class DTOConverters {return Arrays.stream(transforms).map(DTOConverters::toDTO).toArray(Partitioning[]::new);}+ /**+ * Converts an array of Indexes to an array of IndexDTOs.+ *+ * @param indexes The indexes to be converted.+ * @return The array of IndexDTOs.+ */public static IndexDTO[] toDTOs(Index[] indexes) {if (ArrayUtils.isEmpty(indexes)) {return IndexDTO.EMPTY_INDEXES;@@ -339,6 +448,12 @@ public class DTOConverters {return Arrays.stream(indexes).map(DTOConverters::toDTO).toArray(IndexDTO[]::new);}+ /**+ * Converts an array of Partitions to an array of PartitionDTOs.+ *+ * @param partitions The partitions to be converted.+ * @return The array of PartitionDTOs.+ */public static PartitionDTO[] toDTOs(Partition[] partitions) {if (ArrayUtils.isEmpty(partitions)) {return new PartitionDTO[0];@@ -346,6 +461,12 @@ public class DTOConverters {return Arrays.stream(partitions).map(DTOConverters::toDTO).toArray(PartitionDTO[]::new);}+ /**+ * Converts a DistributionDTO to a Distribution.+ *+ * @param distributionDTO The distribution DTO.+ * @return The distribution.+ */public static Distribution fromDTO(DistributionDTO distributionDTO) {if (DistributionDTO.NONE.equals(distributionDTO) || null == distributionDTO) {return Distributions.NONE;@@ -357,6 +478,12 @@ public class DTOConverters {fromFunctionArgs(distributionDTO.args()));}+ /**+ * Converts a FunctionArg DTO to an Expression.+ *+ * @param args The function argument DTOs to be converted.+ * @return The array of Expressions.+ */public static Expression[] fromFunctionArgs(FunctionArg[] args) {if (ArrayUtils.isEmpty(args)) {return Expression.EMPTY_EXPRESSION;@@ -364,6 +491,12 @@ public class DTOConverters {return Arrays.stream(args).map(DTOConverters::fromFunctionArg).toArray(Expression[]::new);}+ /**+ * Converts a FunctionArg DTO to an Expression.+ *+ * @param arg The function argument DTO to be converted.+ * @return The expression.+ */public static Expression fromFunctionArg(FunctionArg arg) {switch (arg.argType()) {case LITERAL:@@ -383,10 +516,22 @@ public class DTOConverters {}}+ /**+ * Converts a IndexDTO to an Index.+ *+ * @param indexDTO The Index DTO to be converted.+ * @return The index.+ */public static Index fromDTO(IndexDTO indexDTO) {return Indexes.of(indexDTO.type(), indexDTO.name(), indexDTO.fieldNames());}+ /**+ * Converts an array of IndexDTOs to an array of Indexes.+ *+ * @param indexDTOS The Index DTOs to be converted.+ * @return The array of Indexes.+ */public static Index[] fromDTOs(IndexDTO[] indexDTOS) {if (ArrayUtils.isEmpty(indexDTOS)) {return Indexes.EMPTY_INDEXES;@@ -395,6 +540,12 @@ public class DTOConverters {return Arrays.stream(indexDTOS).map(DTOConverters::fromDTO).toArray(Index[]::new);}+ /**+ * Converts a PartitionDTO to a Partition.+ *+ * @param partitionDTO The partition DTO to be converted.+ * @return The partition.+ */public static Partition fromDTO(PartitionDTO partitionDTO) {switch (partitionDTO.type()) {case IDENTITY:@@ -420,6 +571,12 @@ public class DTOConverters {}}+ /**+ * Converts a SortOrderDTO to a SortOrder.+ *+ * @param sortOrderDTO The sort order DTO to be converted.+ * @return The sort order.+ */public static SortOrder fromDTO(SortOrderDTO sortOrderDTO) {return SortOrders.of(fromFunctionArg(sortOrderDTO.sortTerm()),@@ -427,6 +584,12 @@ public class DTOConverters {sortOrderDTO.nullOrdering());}+ /**+ * Converts an array of SortOrderDTOs to an array of SortOrders.+ *+ * @param sortOrderDTO The sort order DTOs to be converted.+ * @return The array of SortOrders.+ */public static SortOrder[] fromDTOs(SortOrderDTO[] sortOrderDTO) {if (ArrayUtils.isEmpty(sortOrderDTO)) {return new SortOrder[0];@@ -435,6 +598,12 @@ public class DTOConverters {return Arrays.stream(sortOrderDTO).map(DTOConverters::fromDTO).toArray(SortOrder[]::new);}+ /**+ * Converts an array of Partitioning DTOs to an array of Transforms.+ *+ * @param partitioning The partitioning DTOs to be converted.+ * @return The array of Transforms.+ */public static Transform[] fromDTOs(Partitioning[] partitioning) {if (ArrayUtils.isEmpty(partitioning)) {return new Transform[0];@@ -442,6 +611,12 @@ public class DTOConverters {return Arrays.stream(partitioning).map(DTOConverters::fromDTO).toArray(Transform[]::new);}+ /**+ * Converts a ColumnDTO to a Column.+ *+ * @param columns The column DTO to be converted.+ * @return The column.+ */public static Column[] fromDTOs(ColumnDTO[] columns) {if (ArrayUtils.isEmpty(columns)) {return new Column[0];@@ -449,6 +624,12 @@ public class DTOConverters {return Arrays.stream(columns).map(DTOConverters::fromDTO).toArray(Column[]::new);}+ /**+ * Converts a ColumnDTO to a Column.+ *+ * @param column The column DTO to be converted.+ * @return The column.+ */public static Column fromDTO(ColumnDTO column) {if (column.defaultValue().equals(Column.DEFAULT_VALUE_NOT_SET)) {return column;@@ -462,6 +643,12 @@ public class DTOConverters {fromFunctionArg((FunctionArg) column.defaultValue()));}+ /**+ * Converts a partitioning DTO to a Transform.+ *+ * @param partitioning The partitioning DTO to be converted.+ * @return The transform.+ */public static Transform fromDTO(Partitioning partitioning) {switch (partitioning.strategy()) {case IDENTITY:diff --git a/common/src/main/java/com/datastrato/gravitino/json/JsonUtils.java b/common/src/main/java/com/datastrato/gravitino/json/JsonUtils.javaindex 9da753748b..93d23f21bf 100644--- a/common/src/main/java/com/datastrato/gravitino/json/JsonUtils.java+++ b/common/src/main/java/com/datastrato/gravitino/json/JsonUtils.java@@ -170,11 +170,21 @@ public class JsonUtils {this.elements = pNode.elements();}+ /**+ * Judge whether it has more elements in the JSON array.+ *+ * @return+ */@Overridepublic boolean hasNext() {return elements.hasNext();}+ /**+ * Get a next element from the JSON array.+ *+ * @return+ */@Overridepublic T next() {JsonNode element = elements.next();@@ -237,7 +247,7 @@ public class JsonUtils {* @param node The JSON node.* @return The list of strings or null if property is missing or null.*/- public static List<String> getStringListOrNull(String property, JsonNode node) {+ static List<String> getStringListOrNull(String property, JsonNode node) {if (!node.has(property) || node.get(property).isNull()) {return null;}@@ -254,14 +264,14 @@ public class JsonUtils {* @return The list of strings.* @throws IllegalArgumentException if the property is missing in the JSON node.*/- public static List<String> getStringList(String property, JsonNode node) {+ private static List<String> getStringList(String property, JsonNode node) {Preconditions.checkArgument(node.has(property), "Cannot parse missing property: %s", property);return ImmutableList.<String>builder().addAll(new JsonStringArrayIterator(property, node)).build();}- public static String[] getStringArray(ArrayNode node) {+ private static String[] getStringArray(ArrayNode node) {String[] array = new String[node.size()];for (int i = 0; i < node.size(); i++) {array[i] = node.get(i).asText();@@ -269,6 +279,13 @@ public class JsonUtils {return array;}+ /**+ * Get a int value from a JSON node property.+ *+ * @param property The property name.+ * @param node The JSON node.+ * @return The int value.+ */public static int getInt(String property, JsonNode node) {Preconditions.checkArgument(node.has(property), "Cannot parse missing property: %s", property);JsonNode pNode = node.get(property);@@ -280,6 +297,13 @@ public class JsonUtils {return pNode.asInt();}+ /**+ * Get a long value from a JSON node property.+ *+ * @param property The property name.+ * @param node The JSON node.+ * @return The long value.+ */public static long getLong(String property, JsonNode node) {Preconditions.checkArgument(node.has(property), "Cannot parse missing property: %s", property);JsonNode pNode = node.get(property);@@ -291,7 +315,7 @@ public class JsonUtils {return pNode.asLong();}- public static FunctionArg readFunctionArg(JsonNode node) {+ private static FunctionArg readFunctionArg(JsonNode node) {Preconditions.checkArgument(node != null && !node.isNull() && node.isObject(),"Cannot parse function arg from invalid JSON: %s",@@ -346,7 +370,7 @@ public class JsonUtils {}}- public static void writeFunctionArg(FunctionArg arg, JsonGenerator gen) throws IOException {+ private static void writeFunctionArg(FunctionArg arg, JsonGenerator gen) throws IOException {gen.writeStartObject();gen.writeStringField(EXPRESSION_TYPE, arg.argType().name().toLowerCase());switch (arg.argType()) {@@ -733,6 +757,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for SortOrderDTO objects. */public static class ColumnPositionSerializer extends JsonSerializer<TableChange.ColumnPosition> {@Overridepublic void serialize(@@ -755,6 +780,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for ColumnPosition objects. */public static class ColumnPositionDeserializerextends JsonDeserializer<TableChange.ColumnPosition> {@@ -783,6 +809,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for PartitionDTO objects. */public static class PartitioningSerializer extends JsonSerializer<Partitioning> {@Overridepublic void serialize(Partitioning value, JsonGenerator gen, SerializerProvider serializers)@@ -837,6 +864,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for Partitioning objects. */public static class PartitioningDeserializer extends JsonDeserializer<Partitioning> {@Overridepublic Partitioning deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {@@ -889,6 +917,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for SortOrderDTO objects. */public static class SortOrderSerializer extends JsonSerializer<SortOrderDTO> {@Overridepublic void serialize(SortOrderDTO value, JsonGenerator gen, SerializerProvider serializers)@@ -902,6 +931,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for SortOrderDTO objects. */public static class SortOrderDeserializer extends JsonDeserializer<SortOrderDTO> {@Overridepublic SortOrderDTO deserialize(JsonParser p, DeserializationContext ctxt)@@ -925,6 +955,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for DistributionDTO objects. */public static class DistributionSerializer extends JsonSerializer<DistributionDTO> {@Overridepublic void serialize(DistributionDTO value, JsonGenerator gen, SerializerProvider serializers)@@ -941,6 +972,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for DistributionDTO objects. */public static class DistributionDeserializer extends JsonDeserializer<DistributionDTO> {@Overridepublic DistributionDTO deserialize(JsonParser p, DeserializationContext ctxt)@@ -962,6 +994,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for Column default value. */public static class ColumnDefaultValueSerializer extends JsonSerializer<Expression> {@Overridepublic void serialize(Expression value, JsonGenerator gen, SerializerProvider serializers)@@ -978,6 +1011,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for Column default value. */public static class ColumnDefaultValueDeserializer extends JsonDeserializer<Expression> {@Overridepublic Expression deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {@@ -989,6 +1023,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for PartitionDTO objects. */public static class PartitionDTOSerializer extends JsonSerializer<PartitionDTO> {@Overridepublic void serialize(PartitionDTO value, JsonGenerator gen, SerializerProvider serializers)@@ -1034,6 +1069,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for PartitionDTO objects. */public static class PartitionDTODeserializer extends JsonDeserializer<PartitionDTO> {@Overridepublic PartitionDTO deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {@@ -1118,6 +1154,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for Index objects. */public static class IndexSerializer extends JsonSerializer<Index> {@Overridepublic void serialize(Index value, JsonGenerator gen, SerializerProvider serializers)@@ -1133,6 +1170,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for Index objects. */public static class IndexDeserializer extends JsonDeserializer<Index> {@Overridepublic Index deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {diff --git a/common/src/main/java/com/datastrato/gravitino/rest/RESTMessage.java b/common/src/main/java/com/datastrato/gravitino/rest/RESTMessage.javaindex 6d20a441cd..9850519e97 100644--- a/common/src/main/java/com/datastrato/gravitino/rest/RESTMessage.java+++ b/common/src/main/java/com/datastrato/gravitino/rest/RESTMessage.java@@ -20,6 +20,13 @@ package com.datastrato.gravitino.rest;// Referred from Apache Iceberg's RESTMessage implementation// core/src/main/java/org/apache/iceberg/rest/RESTMessage.java++/**+ * Interface for REST messages.+ *+ * <p>REST messages are objects that are sent to and received from REST endpoints. They are+ * typically used to represent the request and response bodies of REST API calls.+ */public interface RESTMessage {/**diff --git a/common/src/main/java/com/datastrato/gravitino/rest/RESTUtils.java b/common/src/main/java/com/datastrato/gravitino/rest/RESTUtils.javaindex a481df211f..9a22052dc1 100644--- a/common/src/main/java/com/datastrato/gravitino/rest/RESTUtils.java+++ b/common/src/main/java/com/datastrato/gravitino/rest/RESTUtils.java@@ -32,11 +32,11 @@ import java.nio.charset.StandardCharsets;import java.util.Map;import java.util.Random;-/*+/*** Referred from Apache Iceberg's RESTUtil implementation* core/src/main/java/org/apache/iceberg/rest/RESTUtil.java*- * Utility class for working with REST related operations.+ * <p>Utility class for working with REST related operations.*/public class RESTUtils {diff --git a/common/src/main/java/com/datastrato/gravitino/utils/MapUtils.java b/common/src/main/java/com/datastrato/gravitino/utils/MapUtils.javaindex 6b0e2d0984..82799ad6b4 100644--- a/common/src/main/java/com/datastrato/gravitino/utils/MapUtils.java+++ b/common/src/main/java/com/datastrato/gravitino/utils/MapUtils.java@@ -9,7 +9,16 @@ import com.google.common.collect.Maps;import java.util.Collections;import java.util.Map;+/** Utility class for working with maps. */public class MapUtils {++ /**+ * Returns a map with all keys that start with the given prefix.+ *+ * @param m The map to filter.+ * @param prefix The prefix to filter by.+ * @return A map with all keys that start with the given prefix.+ */public static Map<String, String> getPrefixMap(Map<String, String> m, String prefix) {Map<String, String> configs = Maps.newHashMap();m.forEach(@@ -23,6 +32,12 @@ public class MapUtils {return Collections.unmodifiableMap(configs);}+ /**+ * Returns an unmodifiable map.+ *+ * @param m The map to make unmodifiable.+ * @return An unmodifiable map.+ */public static Map<String, String> unmodifiableMap(Map<String, String> m) {return Collections.unmodifiableMap(m);}