AWS Glue Data Catalog functions in DuckDB
Use the AWS Glue Data Catalog functions to read the definitions of the tables and partitions that your queries read. You can also use them to register and change the partitions of Hive tables, and to change the location or the columns of a Hive table.
Functions that change the AWS Glue Data Catalog take effect as soon as they run, and a later failure does not roll them back. Run each one as a query of its own with CALL, for example CALL glue_add_partition('sales_db.orders', {dt: '2026-10-03'}). Replace sales_db.orders with your own table name and '2026-10-03' with your own partition value. These functions change metadata only. They do not create, move, or delete data files in Amazon S3.
Name a table as or database.table. When you leave out the catalog or the database, DuckDB fills it in from the query execution context, as it does for table names in a query.catalog.database.table
This topic shows the functions that read the AWS Glue Data Catalog first, and then the functions that change it, in the order in which their examples ran. The examples change the same tables, so each one starts from the state that the examples before it leave. To get the same results, run the examples in the order of this topic.
The following table lists the AWS Glue Data Catalog functions that this topic describes.
| Function | Description |
|---|---|
Registers a new partition for a Hive table. |
|
Applies a list of partition and location changes to a Hive table in one call. |
|
Removes a partition from the AWS Glue definition of a Hive table and leaves its data files in Amazon S3. |
|
Returns the AWS Glue definition of a database. |
|
Returns the AWS Glue definition of one partition of a Hive table. |
|
Returns the AWS Glue definition of a table, including its location, SerDe, columns, and parameters. |
|
Lists the registered partitions of a Hive table. |
|
Changes the values of a registered partition and keeps its location. |
|
Finds the partition directories under a Hive table's location that no registered partition uses, and registers them in the AWS Glue Data Catalog. |
|
Replaces all the data columns of a Hive table in one call. |
|
Changes the Amazon S3 location of a registered partition. |
|
Changes the Amazon S3 location of a Hive table. |
|
Reads Hive-style data files from an Amazon S3 location, with a schema and partitions that you supply instead of a catalog table. |
glue_get_database_response function
Returns one row that describes a database in the AWS Glue Data Catalog: its name, description, location, and parameters, and the complete AWS Glue Database object in the response column.
If the database does not exist, the query fails.
Syntax
glue_get_database_response(database)
Arguments
The glue_get_database_response function takes the following argument:
database-
The name of the database, as
ordatabase. It must be a constantcatalog.databaseVARCHARvalue.
Return type
A table with one row and the columns database_name (VARCHAR), description (VARCHAR), location_uri (VARCHAR), parameters (MAP(VARCHAR, VARCHAR)), and response (VARIANT).
Examples
The following SQL query returns the name of a database.
SELECT database_name FROM glue_get_database_response('sales_db')
The query returns the following result.
| database_name |
|---|
|
The following SQL query names the database with its catalog and checks whether the database has a description.
SELECT database_name, description IS NULL AS no_description FROM glue_get_database_response( 'awsdatacatalog.sales_db' )
The query returns the following result.
| database_name | no_description |
|---|---|
|
|
Considerations
To read one field of the complete definition, use dot notation on response and cast the result, for example CAST(response.LocationUri AS VARCHAR).
glue_get_table_response function
Returns one row that describes a table in the AWS Glue Data Catalog. The row gives the table's database and name, its table type, its location and SerDe library, its columns and partition keys, and its table and SerDe parameters. The response column holds the complete AWS Glue Table object.
Use glue_get_table_response on Hive tables and on other tables that are registered in the AWS Glue Data Catalog, such as Apache Iceberg tables. The table_type column shows how DuckDB reads the table, for example HIVE or ICEBERG, and glue_table_type shows the AWS Glue table type, for example EXTERNAL_TABLE.
Syntax
glue_get_table_response(table)
Arguments
The glue_get_table_response function takes the following argument:
table-
The name of the table, as
,table, ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue.
Return type
A table with one row and the columns database_name, table_name, table_type, glue_table_type, location, and serde_library (all VARCHAR). The other columns are columns and partition_keys (both STRUCT(name VARCHAR, type VARCHAR, comment VARCHAR)[]), parameters and serde_parameters (both MAP(VARCHAR, VARCHAR)), and response (VARIANT).
Examples
The following SQL query returns the table type and the location of a Hive table.
SELECT table_type, glue_table_type, location FROM glue_get_table_response('sales_db.sales_parquet')
The query returns the following result.
| table_type | glue_table_type | location |
|---|---|---|
|
|
|
The following SQL query uses a table name that includes the catalog, awsdatacatalog, and returns the partition key, the classification, and the field delimiter of a partitioned CSV table.
SELECT partition_keys[1].name AS partition_key, parameters['classification'] AS classification, serde_parameters[ 'field.delim' ] AS field_delimiter FROM glue_get_table_response( 'awsdatacatalog.sales_db.sales_csv' )
The query returns the following result.
| partition_key | classification | field_delimiter |
|---|---|---|
|
|
|
The following SQL query reads the input format from the complete table definition in the response column.
SELECT CAST( response.StorageDescriptor.InputFormat AS VARCHAR ) AS input_format FROM glue_get_table_response('sales_db.sales_parquet')
The query returns the following result.
| input_format |
|---|
|
The following SQL query returns the table type of an Apache Iceberg table and its table_type parameter.
SELECT table_type, parameters['table_type'] AS table_type_parameter FROM glue_get_table_response('sales_db.orders_iceberg')
The query returns the following result.
| table_type | table_type_parameter |
|---|---|
|
|
Considerations
The type field of columns and partition_keys holds the Hive type name that the AWS Glue Data Catalog stores, such as int or string, not the DuckDB type.
The order of the entries in parameters and serde_parameters is not fixed. To read one parameter, select it by key, for example parameters['classification'].
To read one field of the complete definition, use dot notation on response and cast the result, for example CAST(response.StorageDescriptor.InputFormat AS VARCHAR).
Differences from Athena engine version 3
Athena engine version 3 shows the details of a Hive table with DESCRIBE EXTENDED and DESCRIBE FORMATTED, which DuckDB does not support. Use glue_get_table_response to read the location, SerDe, parameters, and partition keys of a Hive table. The result of glue_get_table_response is not formatted like the Athena engine version 3 DESCRIBE output.
In place of the Athena engine version 3 SHOW TBLPROPERTIES statement, use glue_get_table_response for a Hive table, or iceberg_table_properties for an Iceberg table. For more information about iceberg_table_properties, see iceberg_table_properties function.
glue_get_partition_response function
Returns one row that describes one partition of a partitioned Hive table. The row gives the partition's database and table, its partition values, its location and SerDe library, its columns, and its parameters and SerDe parameters. The response column holds the complete AWS Glue Partition object.
Name the partition with a STRUCT that has one field for each partition key of the table. If the partition does not exist, the query fails.
Syntax
glue_get_partition_response(table, partition)
Arguments
The glue_get_partition_response function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. partition-
The partition to describe, as a constant
STRUCTwith one field for each partition key, such as{region: 'east'}. A field set toNULLnames the default partition,__HIVE_DEFAULT_PARTITION__.
Return type
A table with one row and the columns database_name and table_name (both VARCHAR), partition_values (VARCHAR[]), and location and serde_library (both VARCHAR). The other columns are columns (STRUCT(name VARCHAR, type VARCHAR, comment VARCHAR)[]), parameters and serde_parameters (both MAP(VARCHAR, VARCHAR)), and response (VARIANT).
Examples
The following SQL query returns the partition values and the location of one partition.
SELECT partition_values, location FROM glue_get_partition_response( 'sales_db.sales_csv', {region: 'east'} )
The query returns the following result.
| partition_values | location |
|---|---|
|
|
The following SQL query reads the input format of a partition from the complete partition definition in the response column.
SELECT CAST( response.StorageDescriptor.InputFormat AS VARCHAR ) AS input_format FROM glue_get_partition_response( 'sales_db.sales_csv', {region: 'west'} )
The query returns the following result.
| input_format |
|---|
|
Considerations
The function works only on partitioned Hive tables. The partition must name every partition key of the table and no other field.
glue_partitions function
Returns one row for each partition that is registered in the AWS Glue Data Catalog for a partitioned Hive table. The result has one column for each partition key, named after the key and typed as the key. The last two columns are location and partition_values. The partition_values column holds the partition values as the strings that the AWS Glue Data Catalog stores.
Syntax
glue_partitions(table)
Arguments
The glue_partitions function takes the following argument:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue.
Return type
A table with one column for each partition key, typed as the key, then location (VARCHAR) and partition_values (VARCHAR[]).
Examples
The following SQL query lists the partitions of a table and their locations.
SELECT region, location FROM glue_partitions('sales_db.sales_csv') ORDER BY region
The query returns the following results.
| region | location |
|---|---|
|
|
|
|
|
|
The following SQL query filters on the partition key column and returns the stored partition values.
SELECT region, partition_values FROM glue_partitions('sales_db.sales_csv') WHERE region <> 'east' ORDER BY region
The query returns the following results.
| region | partition_values |
|---|---|
|
|
|
|
Considerations
A partition key column is NULL both for the default partition, which the AWS Glue Data Catalog stores as __HIVE_DEFAULT_PARTITION__, and for a stored value that the key's type cannot hold. To tell the two apart, read partition_values, which always holds the stored strings.
If a partition key is itself named location or partition_values, the function's own column of that name gets a numeric suffix, such as location_1.
Differences from Athena engine version 3
In place of the Athena engine version 3 SHOW PARTITIONS statement, use SELECT * FROM glue_partitions('.catalog.database.table')
hive_scan function
Reads the data files under one Amazon S3 location the way DuckDB reads a Hive table, without looking anything up in the AWS Glue Data Catalog. You supply the columns in schema, and for a partitioned layout, the partitions in partitions.
Without partitions, hive_scan reads every data file under location as one unpartitioned table. With partitions, it reads only the partitions that you list. A partition without its own location is read from the directory under key=valuelocation.
Syntax
hive_scan(location, schema := columns
[, format := format ]
[, partitions := partition_list ]
[, partition_keys := key_list ]
[, header := header ] [, delim := delimiter ]
[, quote := quote ] [, escape := escape ]
[, nullstr := null_string ]
[, ignore_errors := ignore_errors ])
Arguments
The hive_scan function takes the following arguments:
location-
The root Amazon S3 location of the data, as a
VARCHARvalue, such as's3://amzn-s3-demo-bucket/orders/'. Give one location, not a list. columns-
The columns of the data, as a
STRUCTthat maps each column name to a type name, such as{id: 'INTEGER', dt: 'VARCHAR'}. List the data columns and the partition columns. This argument is required. format-
The file format, as a
VARCHARvalue:'parquet'(the default),'csv','json', or'avro'. This argument is optional. partition_list-
The partitions to read, as a list of
STRUCTvalues, one for each partition, such as[{dt: '2026-10-01'}, {dt: '2026-10-02'}]. Each value has a field for each partition key and an optionallocationfield. This argument is optional. key_list-
The names of the partition keys in order, as a
VARCHAR[]list. By default, the partition keys are the fields ofpartition_listother thanlocation. Use it only together withpartitions. This argument is optional. header-
The header option for CSV files, as a
BOOLEANvalue. A value oftruemeans that each file starts with a header line. This argument is optional. delimiter-
The field delimiter of CSV files, as a
VARCHARvalue, such as'|'. This argument is optional. quote-
The quote character of CSV files, as a
VARCHARvalue. This argument is optional. escape-
The escape character of CSV files, as a
VARCHARvalue. This argument is optional. null_string-
The string that stands for
NULLin CSV files, as aVARCHARvalue, such as'\N'. This argument is optional. ignore_errors-
The option for lines in JSON files that are not valid JSON, as a
BOOLEANvalue. When it istrue, the function reads such a line as a row ofNULLvalues. This argument is optional.
Return type
A table with the columns that columns names, typed as given.
Examples
The following SQL query reads the Parquet files under one location as an unpartitioned table and counts the rows for each region.
SELECT region, count(*) AS orders FROM hive_scan('s3://amzn-s3-demo-bucket/tables/sales_parquet/', schema := { order_id: 'INTEGER', customer: 'VARCHAR', region: 'VARCHAR', amount: 'DECIMAL(10,2)', order_date: 'DATE' }) GROUP BY region ORDER BY region
The query returns the following results.
| region | orders |
|---|---|
|
|
|
|
|
|
The following SQL query reads CSV files that are partitioned by region in region= directories, and adds up the amounts in each partition.value
SELECT region, sum(amount) AS total FROM hive_scan('s3://amzn-s3-demo-bucket/tables/sales_csv/', schema := { order_id: 'INTEGER', customer: 'VARCHAR', amount: 'DOUBLE', region: 'VARCHAR' }, format := 'csv', partitions := [ {region: 'east'}, {region: 'north'}, {region: 'west'} ]) GROUP BY region ORDER BY region
The query returns the following results.
| region | total |
|---|---|
|
|
|
|
|
|
The following SQL query lists only one partition, so it reads only the files of that partition.
SELECT count(*) AS orders FROM hive_scan('s3://amzn-s3-demo-bucket/tables/sales_csv/', schema := { order_id: 'INTEGER', customer: 'VARCHAR', amount: 'DOUBLE', region: 'VARCHAR' }, format := 'csv', partitions := [{region: 'north'}])
The query returns the following result.
| orders |
|---|
|
The following SQL query lists a partition whose directory holds no data files, so the count is 0.
SELECT count(*) AS orders FROM hive_scan('s3://amzn-s3-demo-bucket/tables/sales_csv/', schema := { order_id: 'INTEGER', customer: 'VARCHAR', amount: 'DOUBLE', region: 'VARCHAR' }, format := 'csv', partitions := [{region: 'south'}])
The query returns the following result.
| orders |
|---|
|
Considerations
CSV columns are matched by position, and JSON and Parquet columns by name. In CSV files, an empty field is NULL unless nullstr says otherwise.
glue_add_partition function
Registers a partition of a partitioned Hive table in the AWS Glue Data Catalog and returns the partition's location. Without location, the function uses a directory under the table location as the partition's location, such as key=values3://amzn-s3-demo-bucket/orders/dt=2026-10-03.
The function registers metadata only. It does not create files or directories in Amazon S3.
Syntax
CALL glue_add_partition(table, partition
[, location := location ]
[, if_not_exists := if_not_exists ])
Arguments
The glue_add_partition function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. partition-
The partition to register, as a constant
STRUCTwith one field for each partition key, such as{dt: '2026-10-03'}. A field set toNULLnames the default partition,__HIVE_DEFAULT_PARTITION__. location-
The Amazon S3 location of the partition's data files, as a
VARCHARvalue. The function removes a trailing slash. This argument is optional. if_not_exists-
The option for a partition that already exists, as a
BOOLEANvalue. Whentrue, the call succeeds without a change if the partition already exists. The default isfalse, which makes the call fail if the partition exists. This argument is optional.
Return type
A table with one row and one column, location (VARCHAR), the location of the partition.
Examples
The following SQL statement registers a partition at the default location under the table location.
CALL glue_add_partition( 'sales_db.partition_demo', {dt: '2026-10-03'} )
The statement returns the following result.
| location |
|---|
|
The following SQL statement registers a partition at a location that you choose. The function removes the trailing slash.
CALL glue_add_partition( 'sales_db.partition_demo', {dt: '2026-10-04'}, location := 's3://amzn-s3-demo-bucket/tables/partition_demo/imports/2026-10-04/' )
The statement returns the following result.
| location |
|---|
|
The following SQL statement tries to add a partition that already exists. With if_not_exists := true, the call succeeds and changes nothing.
CALL glue_add_partition( 'sales_db.partition_demo', {dt: '2026-10-03'}, if_not_exists := true )
The statement returns the following result.
| location |
|---|
|
The following SQL query lists the partitions of the table. The table already had the 2026-10-01 and 2026-10-02 partitions, and the previous examples added 2026-10-03 and 2026-10-04.
SELECT dt, location FROM glue_partitions('sales_db.partition_demo') ORDER BY dt
The query returns the following results.
| dt | location |
|---|---|
|
|
|
|
|
|
|
|
Considerations
With if_not_exists := true and a partition that already exists, the location column shows the location that the call would have registered. It is not necessarily the location of the existing partition. To read the existing location, use the glue_partitions function.
glue_rename_partition function
Changes the partition values of a registered partition of a Hive table and returns the partition's location. The partition keeps its location, so its data files stay where they are, and queries read their rows with the new partition values.
If the partition does not exist, or a partition with the new values already exists, the call fails.
Syntax
CALL glue_rename_partition(table, partition,
new_partition)
Arguments
The glue_rename_partition function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. partition-
The partition to change, as a constant
STRUCTwith one field for each partition key, such as{dt: '2026-10-02'}. new_partition-
The new partition values, as a constant
STRUCTwith one field for each partition key, such as{dt: '2026-10-20'}.
Return type
A table with one row and one column, location (VARCHAR), the location of the partition, which does not change.
Examples
The following SQL statement changes the value of a partition. The result shows the location that the partition keeps.
CALL glue_rename_partition( 'sales_db.partition_demo', {dt: '2026-10-02'}, {dt: '2026-10-20'} )
The statement returns the following result.
| location |
|---|
|
The following SQL query shows the renamed partition and its location.
SELECT dt, location FROM glue_partitions('sales_db.partition_demo') WHERE dt = '2026-10-20'
The query returns the following result.
| dt | location |
|---|---|
|
|
The following SQL query reads the table. The row in the renamed partition now has the new partition value.
SELECT id, dt FROM sales_db.partition_demo ORDER BY id
The query returns the following results.
| id | dt |
|---|---|
|
|
|
|
Considerations
The location does not change to match the new values. For example, after you rename dt=2026-10-02 to dt=2026-10-20, the partition still reads from the dt=2026-10-02 directory. To change the location as well, use the glue_set_partition_location function.
glue_set_partition_location function
Changes the Amazon S3 location of a registered partition of a Hive table and returns the new location. The function changes metadata only. It does not move data files, so after the change the partition reads the files at the new location.
If the partition does not exist, the call fails.
Syntax
CALL glue_set_partition_location(table, partition,
location)
Arguments
The glue_set_partition_location function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. partition-
The partition to change, as a constant
STRUCTwith one field for each partition key, such as{dt: '2026-10-20'}. location-
The new location, as a
VARCHARvalue. It must start withs3://ors3a://and must not beNULLor empty. The function removes a trailing slash.
Return type
A table with one row and one column, location (VARCHAR), the new location of the partition.
Examples
The following SQL statement changes the location of the 2026-10-20 partition to the dt=2026-10-20 directory, which matches its partition value.
CALL glue_set_partition_location( 'sales_db.partition_demo', {dt: '2026-10-20'}, 's3://amzn-s3-demo-bucket/tables/partition_demo/dt=2026-10-20/' )
The statement returns the following result.
| location |
|---|
|
The following SQL query shows the partition's new location.
SELECT dt, location FROM glue_partitions('sales_db.partition_demo') WHERE dt = '2026-10-20'
The query returns the following result.
| dt | location |
|---|---|
|
|
The following SQL query counts the rows in the partition. The data file stayed at the old location, so the partition now reads as empty.
SELECT count(*) AS row_count FROM sales_db.partition_demo WHERE dt = '2026-10-20'
The query returns the following result.
| row_count |
|---|
|
glue_repair_table function
Lists the directories under the location of a partitioned Hive table. Then it registers in the AWS Glue Data Catalog each partition directory that is not yet the location of a registered partition. It returns one row for each partition that it registers. Without missing := true, if every partition is already registered, the result has no rows.
A partition directory has one path component for each partition key, in partition key order, such as key=valuedt=2026-10-02. The function registers the partition at that directory, with the values converted to the types of the partition keys.
With missing := true, the function also reports each registered partition whose location is under the table location but holds no files. The result then has a status column, which is added for a partition that the call registers and missing for a partition whose location holds no files. The function does not remove the missing partitions.
Syntax
CALL glue_repair_table(table [, missing := missing ])
Arguments
The glue_repair_table function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. The table must have a location. missing-
The option to also report the registered partitions whose location holds no files, as a
BOOLEANvalue. Whentrue, the result has a row for each such partition and astatuscolumn. The default isfalse. This argument is optional.
Return type
A table with one row for each partition that the call registers, with one column for each partition key, typed as the key, and location (VARCHAR). With missing := true, the table also has one row for each registered partition whose location holds no files, and a last column, status (VARCHAR), that is added or missing.
Examples
The following SQL statement registers the dt=2026-10-02 directory as a partition. The directory holds a data file, but no registered partition uses it. The glue_rename_partition examples renamed the partition that used it from 2026-10-02 to 2026-10-20, and the glue_set_partition_location examples then changed the location of that partition to the dt=2026-10-20 directory.
CALL glue_repair_table('sales_db.partition_demo')
The statement returns the following result.
| dt | location |
|---|---|
|
|
The following SQL query reads the table. The row whose data file is in the dt=2026-10-02 directory now has the partition value 2026-10-02.
SELECT id, dt FROM sales_db.partition_demo ORDER BY id
The query returns the following results.
| id | dt |
|---|---|
|
|
|
|
The following SQL statement sets missing := true to report the registered partitions whose location holds no files. The glue_add_partition examples registered 2026-10-03 and 2026-10-04 at locations without files. The glue_set_partition_location examples moved 2026-10-20 to a directory without files. The call registers nothing and keeps all three partitions.
CALL glue_repair_table( 'sales_db.partition_demo', missing := true )
The statement returns the following results.
| dt | location | status |
|---|---|---|
|
|
|
|
|
|
|
|
|
Considerations
The function skips directories that hold no data files, directories that do not follow the layout, and directories whose values cannot be converted to the key types. It also skips directories that are already the location of a partition and directories whose values are already registered as a partition at another location.key=value
The function only adds partitions. It never removes a registered partition, even when its directory no longer exists. To find such partitions, set missing := true. To remove one, use the glue_drop_partition function.
With missing := true, the function checks only the registered partitions whose location is under the table location. It does not report a partition at another location, even when that location holds no files. A location counts as holding files when any object is stored under it, even an object that is not a data file.
If a partition key is itself named location or status, the function's own column of that name gets a numeric suffix, such as status_1.
glue_alter_table function
Applies a list of actions to a Hive table: add, drop, or rename partitions, set the location of a partition, and set the location of the table. The function checks every action against the AWS Glue Data Catalog before it applies any of them. If a check fails, the call changes nothing. It returns one row for each action, in the order of the list.
Each action is a STRUCT with an action field and the fields that the action uses. Unlike the other partition functions, glue_alter_table takes each partition as a list of STRUCT values with key and value fields, such as [{key: 'dt', value: '2026-10-05'}].
Syntax
CALL glue_alter_table(table, actions)
Arguments
The glue_alter_table function takes the following arguments:
table-
The name of a Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. Unless every action is'set_table_location', use a partitioned table. actions-
The actions to apply, as a constant list of
STRUCTvalues, one for each action. Theactionfield is one of'add','drop','rename','set_partition_location', or'set_table_location'. Thepartitionfield names the partition that the action changes. Thenew_partitionfield holds the new values for'rename'. Thelocationfield holds the Amazon S3 location for'add'(optional) and for the two location actions. TheBOOLEANfieldsif_not_exists(for'add') andif_exists(for'drop') skip the action instead of failing. A'set_partition_location'action on a partition that does not exist makes the call fail. Leave out the fields that an action does not use.
Return type
A table with one row for each action and the columns action, partition, and location (all VARCHAR). The action column describes the action, such as add partition. The partition column holds the partition values, separated by commas. The location column holds the location that the action set, or NULL when the action sets no location.
Examples
The following SQL statement adds one partition and renames another in one call. The result has one row for each action. The rename row shows NULL in the location column, because a rename keeps the partition's location.
CALL glue_alter_table('sales_db.partition_demo', [ { action: 'add', partition: [{key: 'dt', value: '2026-10-05'}] }, { action: 'rename', partition: [{key: 'dt', value: '2026-10-03'}], new_partition: [ {key: 'dt', value: '2026-10-13'} ] } ])
The statement returns the following results.
| action | partition | location |
|---|---|---|
|
|
|
|
|
|
The following SQL query shows the added partition and the renamed partition, which keeps its location.
SELECT dt, location FROM glue_partitions('sales_db.partition_demo') WHERE dt IN ('2026-10-05', '2026-10-13') ORDER BY dt
The query returns the following results.
| dt | location |
|---|---|
|
|
|
|
Considerations
The function checks all the actions before it applies any of them, but the AWS Glue Data Catalog has no transactions. If a change fails after the checks, for example because of a service error, the changes that the function already applied stay in place.
glue_drop_partition function
Removes a registered partition of a Hive table from the AWS Glue Data Catalog and returns whether it removed one. The partition's data files stay in Amazon S3, and queries of the table no longer read them.
If the partition does not exist, the call fails, unless you set if_exists := true. Then the call succeeds and returns false.
Syntax
CALL glue_drop_partition(table, partition
[, if_exists := if_exists ])
Arguments
The glue_drop_partition function takes the following arguments:
table-
The name of a partitioned Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. partition-
The partition to remove, as a constant
STRUCTwith one field for each partition key, such as{dt: '2026-10-20'}. if_exists-
The option for a partition that does not exist, as a
BOOLEANvalue. Whentrue, the call succeeds if the partition does not exist. The default isfalse. This argument is optional.
Return type
A table with one row and one column, dropped (BOOLEAN), which is true when the call removed the partition.
Examples
The following SQL statement removes the 2026-10-20 partition.
CALL glue_drop_partition( 'sales_db.partition_demo', {dt: '2026-10-20'} )
The statement returns the following result.
| dropped |
|---|
|
The following SQL statement removes the same partition again with if_exists := true. The partition no longer exists, so the call returns false instead of failing.
CALL glue_drop_partition( 'sales_db.partition_demo', {dt: '2026-10-20'}, if_exists := true )
The statement returns the following result.
| dropped |
|---|
|
The following SQL query lists the partitions that remain.
SELECT dt FROM glue_partitions('sales_db.partition_demo') ORDER BY dt
The query returns the following results.
| dt |
|---|
|
|
|
|
|
Considerations
To register the partition again later, use the glue_add_partition function, or glue_repair_table when its directory follows the layout under the table location.key=value
glue_set_table_location function
Changes the Amazon S3 location of a Hive table in the AWS Glue Data Catalog and returns the new location. The function changes metadata only. It does not move data files, so after the change an unpartitioned table reads the files at the new location.
Existing partitions keep their own locations. Partitions that you add later without a location go under the new table location.
Syntax
CALL glue_set_table_location(table, location)
Arguments
The glue_set_table_location function takes the following arguments:
table-
The name of a Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. The table can be partitioned or unpartitioned. location-
The new location, as a
VARCHARvalue. It must start withs3://ors3a://and must not beNULLor empty. The function removes a trailing slash.
Return type
A table with one row and one column, location (VARCHAR), the new location of the table.
Examples
The following SQL statement changes the location of a table.
CALL glue_set_table_location( 'sales_db.location_demo', 's3://amzn-s3-demo-bucket/tables/location_demo_v2/' )
The statement returns the following result.
| location |
|---|
|
The following SQL query reads the new location from the table definition.
SELECT location FROM glue_get_table_response('sales_db.location_demo')
The query returns the following result.
| location |
|---|
|
The following SQL query counts the rows of the table. The data file stayed at the old location, so the table now reads as empty.
SELECT count(*) AS row_count FROM sales_db.location_demo
The query returns the following result.
| row_count |
|---|
|
Differences from Athena engine version 3
In place of the Athena engine version 3 ALTER TABLE statement, use table SET LOCATIONCALL glue_set_table_location. It works on Hive tables only.
glue_replace_columns function
Replaces the whole list of data columns of a Hive table in the AWS Glue Data Catalog and returns the columns as the AWS Glue Data Catalog now stores them. Use it to add, remove, reorder, rename, or widen columns in one call. The partition keys do not change.
The function changes metadata only and does not rewrite data files. DuckDB matches Parquet, JSON, and Avro columns by name. As a result, a renamed column reads as NULL in existing files, and a new column reads as NULL in files written before it. CSV columns are matched by position, so a CSV table must keep its number of columns, and a new name renames the column at that position.
The function removes the comments of columns that you do not list in comments, unless you set keep_comments := true, which keeps the comments of the columns that stay.
Syntax
CALL glue_replace_columns(table, columns
[, comments := comments ]
[, keep_comments := keep_comments ])
Arguments
The glue_replace_columns function takes the following arguments:
table-
The name of a Hive table, as
ordatabase.table. It must be a constantcatalog.database.tableVARCHARvalue. columns-
The new data columns, as a constant
STRUCTthat maps each column name to a type name, in the new column order, such as{id: 'BIGINT', note: 'VARCHAR'}. Do not list the partition keys. A table with bucket or sort columns must keep them. comments-
The column comments to set, as a constant
STRUCTthat maps column names to comments, such as{id: 'order number'}. ANULLcomment removes the comment of that column. This argument is optional. keep_comments-
The option to keep existing comments, as a
BOOLEANvalue. Whentrue, columns that stay keep their comments unlesscommentschanges them. The default isfalse. This argument is optional.
Return type
A table with one row and one column, columns (STRUCT(name VARCHAR, type VARCHAR, comment VARCHAR)[]), the data columns as stored, with Hive type names such as bigint and string.
Examples
The following SQL statement widens the id column from INTEGER to BIGINT, adds a DATE column named added_on, and sets a comment on id.
CALL glue_replace_columns( 'sales_db.columns_demo', {id: 'BIGINT', note: 'VARCHAR', added_on: 'DATE'}, comments := {id: 'order number'} )
The statement returns the following result.
| columns |
|---|
|
The following SQL query reads the table. The new column reads as NULL in the existing data file.
SELECT id, note, added_on FROM sales_db.columns_demo
The query returns the following result.
| id | note | added_on |
|---|---|---|
|
|
|
The following SQL statement removes the added_on column, renames note to memo, and keeps the existing comment on id.
CALL glue_replace_columns( 'sales_db.columns_demo', {id: 'BIGINT', memo: 'VARCHAR'}, keep_comments := true )
The statement returns the following result.
| columns |
|---|
|
The following SQL query reads the table. The table is stored as Parquet, and DuckDB matches Parquet columns by name, so the renamed column reads as NULL.
SELECT id, memo FROM sales_db.columns_demo
The query returns the following result.
| id | memo |
|---|---|
|
|
Considerations
A column that stays can only be widened: from a smaller to a larger integer type, from FLOAT to DOUBLE, or from any type to VARCHAR. Other type changes make the call fail, because existing data files keep their types. In a CSV table, every column stays, matched by position. In other tables, a column stays when the new list has a column with the same name, compared without regard to case.