listDatabases() throws CatalogException {
+ return glueOperator.listGlueDatabases();
+ }
+
+ /**
+ * Get a database from this catalog.
+ *
+ * @param databaseName Name of the database
+ * @return The requested database
+ * @throws DatabaseNotExistException if the database does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogDatabase getDatabase(String databaseName)
+ throws DatabaseNotExistException, CatalogException {
+
+ // glue supports only lowercase naming convention
+ databaseName = databaseName.toLowerCase(Locale.ROOT);
+
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(databaseName));
+ return glueOperator.getDatabase(databaseName);
+ }
+
+ /**
+ * Check if a database exists in this catalog.
+ *
+ * @param databaseName Name of the database
+ * @return true if the given database exists in the catalog false otherwise
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public boolean databaseExists(String databaseName) throws CatalogException {
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(databaseName));
+ try {
+ CatalogDatabase database = getDatabase(databaseName);
+ return database != null;
+ } catch (DatabaseNotExistException e) {
+ return false;
+ }
+ }
+
+ // ------ tables ------
+
+ /**
+ * Creates a new table or view.
+ *
+ * The framework will make sure to call this method with fully validated {@link
+ * ResolvedCatalogTable} or {@link ResolvedCatalogView}. Those instances are easy to serialize
+ * for a durable catalog implementation.
+ *
+ * @param tablePath path of the table or view to be created
+ * @param table the table definition
+ * @param ignoreIfExists flag to specify behavior when a table or view already exists at the
+ * given path: if set to false, it throws a TableAlreadyExistException, if set to true, do
+ * nothing.
+ * @throws TableAlreadyExistException if table already exists and ignoreIfExists is false
+ * @throws DatabaseNotExistException if the database in tablePath doesn't exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists)
+ throws TableAlreadyExistException, DatabaseNotExistException, CatalogException {
+ checkNotNull(tablePath);
+ checkNotNull(table);
+
+ if (!databaseExists(tablePath.getDatabaseName())) {
+ throw new DatabaseNotExistException(getName(), tablePath.getDatabaseName());
+ }
+
+ if (tableExists(tablePath)) {
+ if (!ignoreIfExists) {
+ throw new TableAlreadyExistException(getName(), tablePath);
+ }
+ } else {
+ glueOperator.createGlueTable(tablePath, table, false);
+ }
+ }
+
+ /**
+ * Modifies an existing table or view. Note that the new and old {@link CatalogBaseTable} must
+ * be of the same kind. For example, this doesn't allow altering a regular table to partitioned
+ * table, or altering a view to a table, and vice versa.
+ *
+ *
The framework will make sure to call this method with fully validated {@link
+ * ResolvedCatalogTable} or {@link ResolvedCatalogView}. Those instances are easy to serialize
+ * for a durable catalog implementation.
+ *
+ * @param tablePath path of the table or view to be modified
+ * @param newTable the new table definition
+ * @param ignoreIfNotExists flag to specify behavior when the table or view does not exist: if
+ * set to false, throw an exception, if set to true, do nothing.
+ * @throws TableNotExistException if the table does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterTable(
+ ObjectPath tablePath, CatalogBaseTable newTable, boolean ignoreIfNotExists)
+ throws TableNotExistException, CatalogException {
+
+ checkNotNull(tablePath);
+ checkNotNull(newTable);
+
+ CatalogBaseTable existingTable = getTable(tablePath);
+
+ if (existingTable != null) {
+ if (existingTable.getTableKind() != newTable.getTableKind()) {
+ throw new CatalogException(
+ String.format(
+ "Table types don't match. Existing table is '%s' and new table is '%s'.",
+ existingTable.getTableKind(), newTable.getTableKind()));
+ }
+ glueOperator.alterGlueTable(tablePath, newTable, false);
+ } else if (!ignoreIfNotExists) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+ }
+
+ // ------ tables and views ------
+
+ /**
+ * Drop a table or view.
+ *
+ * @param tablePath Path of the table or view to be dropped
+ * @param ignoreIfNotExists Flag to specify behavior when the table or view does not exist: if
+ * set to false, throw an exception, if set to true, do nothing.
+ * @throws TableNotExistException if the table or view does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
+ throws TableNotExistException, CatalogException {
+ checkNotNull(tablePath);
+ if (tableExists(tablePath)) {
+ glueOperator.deleteGlueTable(tablePath);
+ } else if (!ignoreIfNotExists) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+ }
+
+ /**
+ * Rename an existing table or view.
+ *
+ * @param tablePath Path of the table or view to be renamed
+ * @param newTableName the new name of the table or view
+ * @param ignoreIfNotExists Flag to specify behavior when the table or view does not exist: if
+ * set to false, throw an exception, if set to true, do nothing.
+ * @throws TableNotExistException if the table does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void renameTable(ObjectPath tablePath, String newTableName, boolean ignoreIfNotExists)
+ throws TableNotExistException, TableAlreadyExistException, CatalogException {
+ checkNotNull(tablePath);
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(newTableName));
+
+ if (tableExists(tablePath)) {
+ ObjectPath newTablePath = new ObjectPath(tablePath.getDatabaseName(), newTableName);
+ if (tableExists(newTablePath)) {
+ throw new TableAlreadyExistException(getName(), newTablePath);
+ }
+ glueOperator.renameGlueTable(tablePath, newTablePath);
+ } else if (!ignoreIfNotExists) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+ }
+
+ /**
+ * Get names of all tables and views under this database. An empty list is returned if none
+ * exists.
+ *
+ * @param databaseName fully qualified database name.
+ * @return a list of the names of all tables and views in this database
+ * @throws DatabaseNotExistException if the database does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listTables(String databaseName)
+ throws DatabaseNotExistException, CatalogException {
+ checkArgument(
+ !StringUtils.isNullOrWhitespaceOnly(databaseName));
+
+ if (!databaseExists(databaseName)) {
+ throw new DatabaseNotExistException(getName(), databaseName);
+ }
+ List results = glueOperator.getGlueTableList(databaseName, CatalogBaseTable.TableKind.TABLE.name());
+ results.addAll(listViews(databaseName));
+ return results;
+ }
+
+ /**
+ * Get names of all views under this database. An empty list is returned if none exists.
+ *
+ * @param databaseName the name of the given database
+ * @return a list of the names of all views in the given database
+ * @throws DatabaseNotExistException if the database does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listViews(String databaseName)
+ throws DatabaseNotExistException, CatalogException {
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(databaseName));
+
+ if (!databaseExists(databaseName)) {
+ throw new DatabaseNotExistException(getName(), databaseName);
+ }
+ return glueOperator.getGlueTableList(databaseName, CatalogBaseTable.TableKind.VIEW.name());
+ }
+
+ /**
+ * Returns a {@link CatalogTable} or {@link CatalogView} identified by the given {@link
+ * ObjectPath}. The framework will resolve the metadata objects when necessary.
+ *
+ * @param tablePath Path of the table or view
+ * @return The requested table or view
+ * @throws TableNotExistException if the target does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogTable getTable(ObjectPath tablePath)
+ throws TableNotExistException, CatalogException {
+ checkNotNull(tablePath);
+ if (!tableExists(tablePath)) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+ return glueOperator.getCatalogTableFromGlueTable(glueOperator.getGlueTable(tablePath));
+ }
+
+ /**
+ * Check if a table or view exists in this catalog.
+ *
+ * @param tablePath Path of the table or view
+ * @return true if the given table exists in the catalog false otherwise
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public boolean tableExists(ObjectPath tablePath) throws CatalogException {
+ checkNotNull(tablePath);
+ return databaseExists(tablePath.getDatabaseName()) && glueOperator.glueTableExists(tablePath);
+ }
+
+ // ------ functions ------
+
+ /**
+ * Create a function. Function name should be handled in a case-insensitive way.
+ *
+ * @param path path of the function
+ * @param function the function to be created
+ * @param ignoreIfExists flag to specify behavior if a function with the given name already
+ * exists: if set to false, it throws a FunctionAlreadyExistException, if set to true,
+ * nothing happens.
+ * @throws FunctionAlreadyExistException if the function already exist
+ * @throws DatabaseNotExistException if the given database does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void createFunction(ObjectPath path, CatalogFunction function, boolean ignoreIfExists)
+ throws FunctionAlreadyExistException, DatabaseNotExistException, CatalogException {
+ checkNotNull(path);
+ checkNotNull(function);
+
+ ObjectPath functionPath = normalize(path);
+ if (!databaseExists(functionPath.getDatabaseName())) {
+ throw new DatabaseNotExistException(getName(), functionPath.getDatabaseName());
+ }
+
+ if (functionExists(functionPath)) {
+ if (!ignoreIfExists) {
+ throw new FunctionAlreadyExistException(getName(), functionPath);
+ }
+ }
+ glueOperator.createGlueFunction(functionPath, function);
+ }
+
+ private ObjectPath normalize(ObjectPath path) {
+ return new ObjectPath(
+ path.getDatabaseName(), FunctionIdentifier.normalizeName(path.getObjectName()));
+ }
+
+ /**
+ * Modify an existing function. Function name should be handled in a case-insensitive way.
+ *
+ * @param path path of the function
+ * @param newFunction the function to be modified
+ * @param ignoreIfNotExists flag to specify behavior if the function does not exist: if set to
+ * false, throw an exception if set to true, nothing happens
+ * @throws FunctionNotExistException if the function does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterFunction(
+ ObjectPath path, CatalogFunction newFunction, boolean ignoreIfNotExists)
+ throws FunctionNotExistException, CatalogException {
+ checkNotNull(path);
+ checkNotNull(newFunction);
+
+ ObjectPath functionPath = normalize(path);
+
+ CatalogFunction existingFunction = getFunction(functionPath);
+
+ if (existingFunction != null) {
+ if (existingFunction.getClass() != newFunction.getClass()) {
+ throw new CatalogException(
+ String.format(
+ "Function types don't match. Existing function is '%s' and new function is '%s'.",
+ existingFunction.getClass().getName(),
+ newFunction.getClass().getName()));
+ }
+
+ glueOperator.alterGlueFunction(functionPath, newFunction);
+ } else if (!ignoreIfNotExists) {
+ throw new FunctionNotExistException(getName(), functionPath);
+ }
+ }
+
+ /**
+ * Drop a function. Function name should be handled in a case-insensitive way.
+ *
+ * @param path path of the function to be dropped
+ * @param ignoreIfNotExists flag to specify behavior if the function does not exist: if set to
+ * false, throw an exception if set to true, nothing happens
+ * @throws FunctionNotExistException if the function does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void dropFunction(ObjectPath path, boolean ignoreIfNotExists)
+ throws FunctionNotExistException, CatalogException {
+ checkNotNull(path);
+
+ ObjectPath functionPath = normalize(path);
+
+ if (functionExists(functionPath)) {
+ glueOperator.dropGlueFunction(functionPath);
+ } else if (!ignoreIfNotExists) {
+ throw new FunctionNotExistException(getName(), functionPath);
+ }
+ }
+
+
+ /**
+ * List the names of all functions in the given database. An empty list is returned if none is
+ * registered.
+ *
+ * @param databaseName name of the database.
+ * @return a list of the names of the functions in this database
+ * @throws DatabaseNotExistException if the database does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listFunctions(String databaseName)
+ throws DatabaseNotExistException, CatalogException {
+
+ databaseName = databaseName.toLowerCase(Locale.ROOT);
+ checkArgument(
+ !StringUtils.isNullOrWhitespaceOnly(databaseName),
+ "databaseName cannot be null or empty");
+
+ if (!databaseExists(databaseName)) {
+ throw new DatabaseNotExistException(getName(), databaseName);
+ }
+
+ return glueOperator.listGlueFunctions(databaseName);
+ }
+
+ /**
+ * Get the function. Function name should be handled in a case-insensitive way.
+ *
+ * @param path path of the function
+ * @return the requested function
+ * @throws FunctionNotExistException if the function does not exist in the catalog
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogFunction getFunction(ObjectPath path)
+ throws FunctionNotExistException, CatalogException {
+ checkNotNull(path);
+
+ ObjectPath functionPath = normalize(path);
+
+ if (!functionExists(functionPath)) {
+ throw new FunctionNotExistException(getName(), functionPath);
+ } else {
+ return glueOperator.getGlueFunction(functionPath);
+ }
+ }
+
+ /**
+ * Check whether a function exists or not. Function name should be handled in a case-insensitive
+ * way.
+ *
+ * @param path path of the function
+ * @return true if the function exists in the catalog false otherwise
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public boolean functionExists(ObjectPath path) throws CatalogException {
+ checkNotNull(path);
+ ObjectPath functionPath = normalize(path);
+ return databaseExists(functionPath.getDatabaseName()) && glueOperator.glueFunctionExists(functionPath);
+ }
+
+ /**
+ * Create a partition.
+ *
+ * @param tablePath path of the table.
+ * @param partitionSpec partition spec of the partition
+ * @param partition the partition to add.
+ * @param ignoreIfExists flag to specify behavior if a table with the given name already exists:
+ * if set to false, it throws a TableAlreadyExistException, if set to true, nothing happens.
+ * @throws TableNotExistException thrown if the target table does not exist
+ * @throws TableNotPartitionedException thrown if the target table is not partitioned
+ * @throws PartitionSpecInvalidException thrown if the given partition spec is invalid
+ * @throws PartitionAlreadyExistsException thrown if the target partition already exists
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void createPartition(
+ ObjectPath tablePath,
+ CatalogPartitionSpec partitionSpec,
+ CatalogPartition partition,
+ boolean ignoreIfExists)
+ throws TableNotExistException, TableNotPartitionedException,
+ PartitionSpecInvalidException, PartitionAlreadyExistsException,
+ CatalogException {
+ checkNotNull(tablePath);
+ checkNotNull(partitionSpec);
+ checkNotNull(partition);
+
+ Table glueTable = glueOperator.getGlueTable(tablePath);
+ glueOperator.ensurePartitionedTable(tablePath, glueTable);
+
+ if (partitionExists(tablePath, partitionSpec)) {
+ if (!ignoreIfExists) {
+ throw new PartitionAlreadyExistsException (getName(), tablePath, partitionSpec);
+ }
+ }
+ glueOperator.createGluePartition(glueTable, partitionSpec, partition);
+ }
+
+ /**
+ * Get CatalogPartitionSpec of all partitions of the table.
+ *
+ * @param tablePath path of the table
+ * @return a list of CatalogPartitionSpec of the table
+ * @throws TableNotExistException thrown if the table does not exist in the catalog
+ * @throws TableNotPartitionedException thrown if the table is not partitioned
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listPartitions(ObjectPath tablePath)
+ throws TableNotExistException, TableNotPartitionedException, CatalogException {
+
+ checkNotNull(tablePath);
+ if (!tableExists(tablePath)) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+
+ if (!isPartitionedTable(tablePath)) {
+ throw new TableNotPartitionedException(getName(), tablePath);
+ }
+
+ return glueOperator.listAllGluePartitions(tablePath);
+ }
+
+ private boolean isPartitionedTable(ObjectPath tablePath) {
+ CatalogTable table;
+ try {
+ table = getTable(tablePath);
+ } catch (TableNotExistException e) {
+ return false;
+ }
+ return (table != null) && table.isPartitioned();
+ }
+
+ /**
+ * Get CatalogPartitionSpec of all partitions that is under the given CatalogPartitionSpec in
+ * the table.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec the partition spec to list
+ * @return a list of CatalogPartitionSpec that is under the given CatalogPartitionSpec in the
+ * table
+ * @throws TableNotExistException thrown if the table does not exist in the catalog
+ * @throws TableNotPartitionedException thrown if the table is not partitioned
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listPartitions(
+ ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
+ throws TableNotExistException, TableNotPartitionedException,
+ PartitionSpecInvalidException, CatalogException {
+
+ checkNotNull(tablePath);
+ checkNotNull(partitionSpec);
+
+ if (!tableExists(tablePath)) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+
+ if (!isPartitionedTable(tablePath)) {
+ throw new TableNotPartitionedException(getName(), tablePath);
+ }
+ return glueOperator.listGluePartitions(tablePath, partitionSpec);
+ }
+
+ /**
+ * Get CatalogPartitionSpec of partitions by expression filters in the table.
+ *
+ * NOTE: For FieldReferenceExpression, the field index is based on schema of this table
+ * instead of partition columns only.
+ *
+ *
The passed in predicates have been translated in conjunctive form.
+ *
+ *
If catalog does not support this interface at present, throw an {@link
+ * UnsupportedOperationException} directly. If the catalog does not have a valid filter, throw
+ * the {@link UnsupportedOperationException} directly. Planner will fallback to get all
+ * partitions and filter by itself.
+ *
+ * @param tablePath path of the table
+ * @param filters filters to push down filter to catalog
+ * @return a list of CatalogPartitionSpec that is under the given CatalogPartitionSpec in the
+ * table
+ * @throws TableNotExistException thrown if the table does not exist in the catalog
+ * @throws TableNotPartitionedException thrown if the table is not partitioned
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public List listPartitionsByFilter(
+ ObjectPath tablePath, List filters)
+ throws TableNotExistException, TableNotPartitionedException, CatalogException {
+ checkNotNull(tablePath, "Table path cannot be null");
+ if (!tableExists(tablePath)) {
+ throw new TableNotExistException(getName(), tablePath);
+ }
+
+ if (!isPartitionedTable(tablePath)) {
+ throw new TableNotPartitionedException(getName(), tablePath);
+ }
+
+ return glueOperator.listGluePartitionsByFilter(tablePath, filters);
+ }
+
+ /**
+ * Get a partition of the given table. The given partition spec keys and values need to be
+ * matched exactly for a result.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of partition to get
+ * @return the requested partition
+ * @throws PartitionNotExistException thrown if the partition doesn't exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
+ throws PartitionNotExistException, CatalogException {
+ checkNotNull(tablePath, "Table path cannot be null");
+ checkNotNull(partitionSpec, "CatalogPartitionSpec cannot be null");
+
+ Partition gluePartition = glueOperator.getGluePartition(tablePath, partitionSpec);
+
+ Map properties = gluePartition.parameters();
+
+ properties.put(
+ GlueCatalogConfig.TABLE_LOCATION_URI, gluePartition.storageDescriptor().location());
+
+ String comment = properties.remove(GlueCatalogConfig.COMMENT);
+ return new CatalogPartitionImpl(properties, comment);
+ }
+
+ /**
+ * Check whether a partition exists or not.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition to check
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public boolean partitionExists(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
+ throws CatalogException {
+ checkNotNull(tablePath);
+
+ if (!databaseExists(tablePath.getDatabaseName()) || !tableExists(tablePath)) {
+ throw new CatalogException("Database/Table Doesn't exists.");
+ }
+ return glueOperator.gluePartitionExists(tablePath, partitionSpec);
+
+ }
+
+ /**
+ * Drop a partition.
+ *
+ * @param tablePath path of the table.
+ * @param partitionSpec partition spec of the partition to drop
+ * @param ignoreIfNotExists flag to specify behavior if the database does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws PartitionNotExistException thrown if the target partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void dropPartition(
+ ObjectPath tablePath, CatalogPartitionSpec partitionSpec, boolean ignoreIfNotExists)
+ throws PartitionNotExistException, CatalogException {
+ checkNotNull(tablePath);
+ checkNotNull(partitionSpec);
+ CatalogPartition partition = getPartition(tablePath, partitionSpec);
+
+ if (partition != null) {
+ glueOperator.dropGluePartition(tablePath, partitionSpec);
+ } else if (!ignoreIfNotExists) {
+ throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
+ }
+ }
+
+ /**
+ * Alter a partition.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition
+ * @param newPartition new partition to replace the old one
+ * @param ignoreIfNotExists flag to specify behavior if the database does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws PartitionNotExistException thrown if the target partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterPartition(
+ ObjectPath tablePath,
+ CatalogPartitionSpec partitionSpec,
+ CatalogPartition newPartition,
+ boolean ignoreIfNotExists)
+ throws PartitionNotExistException, CatalogException {
+
+ checkNotNull(tablePath, "Table path cannot be null");
+ checkNotNull(partitionSpec, "CatalogPartitionSpec cannot be null");
+ checkNotNull(newPartition, "New partition cannot be null");
+ CatalogPartition existingPartition = getPartition(tablePath, partitionSpec);
+ if (existingPartition != null) {
+ glueOperator.alterGluePartition(tablePath, partitionSpec, newPartition);
+
+ } else if (!ignoreIfNotExists) {
+ throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
+ }
+ }
+
+ /**
+ * Get the statistics of a table.
+ *
+ * @param tablePath path of the table
+ * @return statistics of the given table
+ * @throws TableNotExistException if the table does not exist in the catalog
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogTableStatistics getTableStatistics(ObjectPath tablePath)
+ throws TableNotExistException, CatalogException {
+ return null;
+
+ }
+
+ /**
+ * Get the column statistics of a table.
+ *
+ * @param tablePath path of the table
+ * @return column statistics of the given table
+ * @throws TableNotExistException if the table does not exist in the catalog
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogColumnStatistics getTableColumnStatistics(ObjectPath tablePath)
+ throws TableNotExistException, CatalogException {
+ return null;
+ }
+
+ /**
+ * Get the statistics of a partition.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition
+ * @return statistics of the given partition
+ * @throws PartitionNotExistException if the partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogTableStatistics getPartitionStatistics(
+ ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
+ throws PartitionNotExistException, CatalogException {
+ return null;
+ }
+
+ /**
+ * Get the column statistics of a partition.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition
+ * @return column statistics of the given partition
+ * @throws PartitionNotExistException if the partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public CatalogColumnStatistics getPartitionColumnStatistics(
+ ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
+ throws PartitionNotExistException, CatalogException {
+ return null;
+ }
+
+ /**
+ * Update the statistics of a table.
+ *
+ * @param tablePath path of the table
+ * @param tableStatistics new statistics to update
+ * @param ignoreIfNotExists flag to specify behavior if the table does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws TableNotExistException if the table does not exist in the catalog
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterTableStatistics(
+ ObjectPath tablePath, CatalogTableStatistics tableStatistics, boolean ignoreIfNotExists)
+ throws TableNotExistException, CatalogException {
+ throw new UnsupportedOperationException("Operation with Statistics not supported.");
+
+ }
+
+ /**
+ * Update the column statistics of a table.
+ *
+ * @param tablePath path of the table
+ * @param columnStatistics new column statistics to update
+ * @param ignoreIfNotExists flag to specify behavior if the table does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws TableNotExistException if the table does not exist in the catalog
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterTableColumnStatistics(
+ ObjectPath tablePath,
+ CatalogColumnStatistics columnStatistics,
+ boolean ignoreIfNotExists)
+ throws TableNotExistException, CatalogException, TablePartitionedException {
+ throw new UnsupportedOperationException("Operation with Statistics not supported.");
+ }
+
+ /**
+ * Update the statistics of a table partition.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition
+ * @param partitionStatistics new statistics to update
+ * @param ignoreIfNotExists flag to specify behavior if the partition does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws PartitionNotExistException if the partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterPartitionStatistics(
+ ObjectPath tablePath,
+ CatalogPartitionSpec partitionSpec,
+ CatalogTableStatistics partitionStatistics,
+ boolean ignoreIfNotExists)
+ throws PartitionNotExistException, CatalogException {
+ throw new UnsupportedOperationException("Operation with Statistics not supported.");
+ }
+
+ /**
+ * Update the column statistics of a table partition.
+ *
+ * @param tablePath path of the table
+ * @param partitionSpec partition spec of the partition @@param columnStatistics new column
+ * statistics to update
+ * @param columnStatistics column related statistics
+ * @param ignoreIfNotExists flag to specify behavior if the partition does not exist: if set to
+ * false, throw an exception, if set to true, nothing happens.
+ * @throws PartitionNotExistException if the partition does not exist
+ * @throws CatalogException in case of any runtime exception
+ */
+ @Override
+ public void alterPartitionColumnStatistics(
+ ObjectPath tablePath,
+ CatalogPartitionSpec partitionSpec,
+ CatalogColumnStatistics columnStatistics,
+ boolean ignoreIfNotExists)
+ throws PartitionNotExistException, CatalogException {
+ throw new UnsupportedOperationException("Operation with Statistics not supported.");
+ }
+}
diff --git a/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogConfig.java b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogConfig.java
new file mode 100644
index 000000000..1f8879964
--- /dev/null
+++ b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogConfig.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog.glue;
+
+import java.util.regex.Pattern;
+
+/** Configs for catalog meta-objects in {@link GlueCatalog}. */
+public class GlueCatalogConfig {
+ // Table related config.
+ public static final String COMMENT = "comment";
+ public static final String DEFAULT_SEPARATOR = ":";
+ public static final String LOCATION_SEPARATOR = "/";
+ public static final String TABLE_OWNER = "owner";
+
+ // Location related config.
+ public static final String TABLE_LOCATION_URI = "glue.table.location-uri";
+ public static final String TABLE_INPUT_FORMAT = "glue.table.input.format";
+ public static final String TABLE_OUTPUT_FORMAT = "glue.table.output.format";
+ public static final String LOCATION_URI = "location-uri";
+
+
+ public static final String FLINK_SCALA_FUNCTION_PREFIX = "flink:scala:";
+ public static final String FLINK_PYTHON_FUNCTION_PREFIX = "flink:python:";
+ public static final String FLINK_JAVA_FUNCTION_PREFIX = "flink:java:";
+
+ public static final String FLINK_CATALOG = "FLINK_CATALOG";
+ public static final String LAST_ACCESS_TIME = "last_access_time";
+ public static final Pattern GLUE_DB_PATTERN = Pattern.compile("^[a-z0-9_]{1,252}$");
+
+ public static final String AND = "and";
+ public static final String NEXT_LINE = "\n";
+
+ public static final CharSequence SPACE = " ";
+ public static final String GLUE_EXCEPTION_MSG_IDENTIFIER = "GLUE EXCEPTION";
+
+ public static final String TABLE_NOT_EXISTS_IDENTIFIER = "TABLE DOESN'T EXISTS";
+ public static final String DATABASE_LOCATION_URI = "glue.database.location-uri";
+ public static final String DEFAULT_PARTITION_NAME = "__GLUE_DEFAULT_PARTITION__";
+}
diff --git a/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactory.java b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactory.java
new file mode 100644
index 000000000..475543104
--- /dev/null
+++ b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactory.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog.glue;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.factories.CatalogFactory;
+import org.apache.flink.table.factories.FactoryUtil;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.table.catalog.glue.GlueCatalogFactoryOptions.DEFAULT_DATABASE;
+import static org.apache.flink.table.catalog.glue.GlueCatalogFactoryOptions.INPUT_FORMAT;
+import static org.apache.flink.table.catalog.glue.GlueCatalogFactoryOptions.LOCATION_URI;
+import static org.apache.flink.table.catalog.glue.GlueCatalogFactoryOptions.OUTPUT_FORMAT;
+import static org.apache.flink.table.factories.FactoryUtil.PROPERTY_VERSION;
+
+/** Catalog factory for {@link GlueCatalog}. */
+public class GlueCatalogFactory implements CatalogFactory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GlueCatalogFactory.class);
+
+ @Override
+ public String factoryIdentifier() {
+ return GlueCatalogFactoryOptions.IDENTIFIER;
+ }
+
+ @Override
+ public Set> requiredOptions() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set> optionalOptions() {
+ final Set> options = new HashSet<>();
+ options.add(DEFAULT_DATABASE);
+ options.add(PROPERTY_VERSION);
+ options.add(LOCATION_URI);
+ options.add(INPUT_FORMAT);
+ options.add(OUTPUT_FORMAT);
+ return options;
+ }
+
+ @Override
+ public Catalog createCatalog(Context context) {
+ final FactoryUtil.CatalogFactoryHelper helper =
+ FactoryUtil.createCatalogFactoryHelper(this, context);
+ helper.validate();
+ LOG.info("Config Info");
+ String msg = context.getOptions().entrySet().stream()
+ .map(entry -> entry.getKey() + "-> " + entry.getValue()).collect(Collectors.joining("\n"));
+ LOG.info("Config Map: " + msg);
+ return new GlueCatalog(
+ context.getName(), helper.getOptions().get(DEFAULT_DATABASE), context.getOptions());
+ }
+}
diff --git a/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactoryOptions.java b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactoryOptions.java
new file mode 100644
index 000000000..70e0c8511
--- /dev/null
+++ b/flink-catalog-aws-glue/src/main/java/org/apache/flink/table/catalog/glue/GlueCatalogFactoryOptions.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog.glue;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.ConfigOptions;
+
+import java.util.Map;
+
+/** {@link ConfigOption}s for {@link GlueCatalog}. */
+@Internal
+public class GlueCatalogFactoryOptions {
+
+ public static final String IDENTIFIER = "glue";
+
+ public static final ConfigOption DEFAULT_DATABASE =
+ ConfigOptions.key(GlueCatalogOptions.DEFAULT_DATABASE_KEY)
+ .stringType()
+ .defaultValue(GlueCatalog.DEFAULT_DB);
+
+ public static final ConfigOption