mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 00:21:51 -05:00
500 lines
35 KiB
Markdown
500 lines
35 KiB
Markdown
# Glue
|
|
|
|
**Protocol:** JSON 1.1
|
|
**Endpoint:** `http://localhost:4566/`
|
|
|
|
Floci emulates the AWS Glue Data Catalog (databases, tables, partitions, functions, connections) and Glue Schema Registry, allowing you to manage local data lake metadata and schema-version workflows.
|
|
|
|
Table and partition column-statistics reads fill omitted required numeric members with `0` for
|
|
string, binary, long, double, decimal, date, and boolean statistics. Supplied values and stored
|
|
records are preserved; optional minimum and maximum values remain absent when omitted.
|
|
|
|
Table and partition reads (`GetTable`, `GetTables`, `SearchTables`, `GetTableVersion`, `GetTableVersions`,
|
|
`GetPartition`, `GetPartitions`, `BatchGetPartition`) return a table's `Retention` as `0`, and a storage
|
|
descriptor's `Compressed`, `NumberOfBuckets`, `SortColumns` and `StoredAsSubDirectories` as `false`, `0`, `[]`
|
|
and `false`, when they were written without them, as Glue does. A table's `IsRegisteredWithLakeFormation` is
|
|
`false`: Floci does not tie a table to a location registered with Lake Formation. The Glue Data Catalog client
|
|
that Hive and Spark use on EMR reads each of them. Stored records keep what was written, and a storage
|
|
descriptor keeps the `AdditionalLocations`, `BucketColumns`, `SortColumns`, `SkewedInfo` and
|
|
`StoredAsSubDirectories` it was given. A `SortColumns` entry that is null, lacks its required `Column` or
|
|
`SortOrder`, or has a `SortOrder` other than `0` or `1` fails the whole `CreateTable`, `UpdateTable`,
|
|
`CreatePartition`, `UpdatePartition`, `BatchCreatePartition` or `BatchUpdatePartition` with a
|
|
`ValidationException`, before anything is stored.
|
|
|
|
## Supported Actions
|
|
|
|
### Data Catalog
|
|
|
|
#### Databases
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateDatabase | Creates a database in the local Glue Data Catalog. |
|
|
| GetDatabase | Returns a stored Data Catalog database. |
|
|
| GetDatabases | Lists databases in pages using `MaxResults` and `NextToken`. |
|
|
| DeleteDatabase | Deletes a database from the local Glue Data Catalog. |
|
|
|
|
#### Tables
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateTable | Creates a table definition in the local Glue Data Catalog. |
|
|
| GetTable | Returns a stored table definition and resolves schema references when possible. |
|
|
| GetTables | Lists table definitions for a database in pages using `MaxResults` and `NextToken`. |
|
|
| UpdateTable | Replaces a table definition; the previous version is archived unless `SkipArchive` is set. |
|
|
| DeleteTable | Deletes a table definition from a database. |
|
|
| BatchDeleteTable | Deletes several tables of a database, reporting the missing ones in `Errors`. |
|
|
| GetTableVersions | Lists the current and archived versions of a table, newest first, in pages using `MaxResults` and `NextToken`. |
|
|
| GetTableVersion | Returns one version by `VersionId`, or the current version when none is given. |
|
|
| DeleteTableVersion | Deletes an archived version; the current version cannot be deleted, as on AWS. |
|
|
| BatchDeleteTableVersion | Deletes several archived versions, reporting the ones not deleted in `Errors`. |
|
|
| SearchTables | Searches every table of the catalog by `SearchText` (substring, or exact when quoted), property `Filters` (string keys use the tokenised match of the API reference, time keys honour `Comparator`, other keys read table parameters) and `SortCriteria`, paged by `MaxResults` and `NextToken`. |
|
|
|
|
`BatchDeleteTable` requires `TablesToDelete` with 0 to 100 names. Missing or oversized lists
|
|
fail with `InvalidInputException` before any table is deleted. Valid batches keep their per-table
|
|
`Errors` response.
|
|
|
|
#### Partitions
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreatePartition | Creates a partition for a Data Catalog table. |
|
|
| GetPartitions | Lists partitions stored for a Data Catalog table in pages using `MaxResults` and `NextToken`. With a `Segment`, returns that segment's share of them: each partition is in exactly one of `TotalSegments` (1 to 10) segments; a `Segment` member that is not an integer is a `SerializationException`. AWS documents `SegmentNumber` values from 0 through `TotalSegments` minus 1 and not what a larger one returns, so a `SegmentNumber` of `TotalSegments` or more returning no partitions is Floci's reading. |
|
|
| BatchDeletePartition | Deletes up to 25 partitions, reporting the ones not found in `Errors`. |
|
|
| CreatePartitionIndex | Registers a partition index on a table. Keys must name partition columns, and a table holds at most 3 indexes. The index reports `CREATING` before `ACTIVE`. |
|
|
| GetPartitionIndexes | Lists a table's partition indexes, each with its keys resolved to name and type. |
|
|
| DeletePartitionIndex | Removes a partition index from a table. The index reports `DELETING` before it disappears. |
|
|
|
|
Partition indexes carry the AWS lifecycle. A new index reports `CREATING` and then `ACTIVE`; a
|
|
deleted one reports `DELETING` and then disappears. As on AWS, only one index per table may be
|
|
created or deleted at a time, and an index that is still `CREATING` cannot be deleted yet.
|
|
|
|
The transitions are driven by reads rather than by a timer, so they are deterministic: each
|
|
`GetPartitionIndexes` reports the current state and settles it, and a client that polls (as the
|
|
Terraform provider does) converges on its next call. The `FAILED` state is not emulated, since it
|
|
only arises from a backfill failure.
|
|
|
|
#### User-defined Functions
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateUserDefinedFunction | Creates a user-defined function in the Data Catalog. |
|
|
| GetUserDefinedFunction | Returns a stored user-defined function. |
|
|
| GetUserDefinedFunctions | Lists user-defined functions for a database. |
|
|
| UpdateUserDefinedFunction | Updates a stored user-defined function. |
|
|
| DeleteUserDefinedFunction | Deletes a user-defined function from a database. |
|
|
|
|
#### Connections
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateConnection | Creates a connection definition from a `ConnectionInput`, with optional `Tags`, and answers `CreateConnectionStatus: READY`. |
|
|
| GetConnection | Returns a stored connection. `HidePassword` omits `PASSWORD` and `ENCRYPTED_PASSWORD` from `ConnectionProperties`. |
|
|
| GetConnections | Lists connections, narrowed by `Filter.MatchCriteria`, `Filter.ConnectionType` and `Filter.ConnectionSchemaVersion`, paged by `MaxResults` and `NextToken`. |
|
|
| UpdateConnection | Redefines a connection from a full `ConnectionInput`, as on AWS: members left out of the input are dropped; the name and `CreationTime` are kept. |
|
|
| DeleteConnection | Deletes a connection and its tags. |
|
|
| BatchDeleteConnection | Deletes up to 25 connections, reporting the ones not found in `Errors`. |
|
|
| TestConnection | Accepts a connection name or an inline `TestConnectionInput` and answers with an empty body. |
|
|
|
|
`ConnectionInput` is validated against the API reference: `Name` (1 to 255 characters), `ConnectionType`
|
|
(the documented enumeration) and `ConnectionProperties` (the documented key list, at most 100 entries, and
|
|
empty for a `NETWORK` connection) are required; `MatchCriteria` holds at most 10 entries. Credentials given
|
|
under `AuthenticationConfiguration` are accepted and never returned by a read. A connection that uses
|
|
`AuthenticationConfiguration` or the `SparkProperties`, `AthenaProperties` or `PythonProperties` maps reports
|
|
`ConnectionSchemaVersion` 2; the classic JDBC, Kafka and network shape reports 1.
|
|
|
|
`HidePassword` removes `PASSWORD` and `ENCRYPTED_PASSWORD`, the two members the API reference defines as the
|
|
connection's password. The Kafka credentials (`KAFKA_CLIENT_KEYSTORE_PASSWORD`, `KAFKA_CLIENT_KEY_PASSWORD`,
|
|
`KAFKA_SASL_PLAIN_PASSWORD`, `KAFKA_SASL_SCRAM_PASSWORD` and their `ENCRYPTED_` forms) are returned as stored: the
|
|
reference does not say whether the flag covers them, so Floci does not guess. The `ENCRYPTED_` forms are what the
|
|
catalog's `ConnectionPasswordEncryption` setting produces (see Encryption settings below).
|
|
|
|
`TestConnection` is asynchronous on AWS and returns nothing; Floci checks the request's shape and accepts it
|
|
without opening a socket to the data store, since no job or crawler runs against a connection yet.
|
|
|
|
#### Resource policy
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| PutResourcePolicy | Sets the catalog's resource policy from `PolicyInJson` and returns its `PolicyHash`. `PolicyExistsCondition` (`NOT_EXIST`, `MUST_EXIST`, `NONE`) and `PolicyHashCondition` are checked against the stored policy and fail with `ConditionCheckFailureException`. |
|
|
| GetResourcePolicy | Returns the catalog policy with its hash and timestamps, or `EntityNotFoundException` when none is set. |
|
|
| GetResourcePolicies | Lists the catalog policy (zero or one entry) under `GetResourcePoliciesResponseList`, paged. |
|
|
| DeleteResourcePolicy | Deletes the catalog policy; honours `PolicyHashCondition`; `EntityNotFoundException` when none is set. |
|
|
|
|
The catalog holds one policy, as on AWS. `PolicyInJson` must be a JSON object. AWS documents `PolicyHash` only as
|
|
an opaque value to echo back; Floci derives it from the document, so the same policy always has the same hash.
|
|
`ResourceArn` ("for internal use only" in the reference) and `EnableHybrid` are accepted. Per-resource policies
|
|
that Resource Access Manager creates on AWS are not emulated, so `GetResourcePolicies` never has more than one entry.
|
|
|
|
#### Encryption settings
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| GetDataCatalogEncryptionSettings | Returns the catalog's security configuration: `EncryptionAtRest` (`CatalogEncryptionMode` `DISABLED` by default) and `ConnectionPasswordEncryption` (`ReturnConnectionPasswordEncrypted` false by default). |
|
|
| PutDataCatalogEncryptionSettings | Replaces the configuration. `CatalogEncryptionMode` is `DISABLED`, `SSE-KMS` or `SSE-KMS-WITH-SERVICE-ROLE`; `ReturnConnectionPasswordEncrypted` is required inside its block. A block left out keeps its default. |
|
|
|
|
`EncryptionAtRest` is stored and reported; catalog metadata is not encrypted on disk, which nothing observes through
|
|
the API. `ConnectionPasswordEncryption` is applied: while `ReturnConnectionPasswordEncrypted` is true, a connection
|
|
created or updated has each password property encrypted with `AwsKmsKeyId` through Floci's KMS and stored under the
|
|
name the `Connection` structure documents for it (`PASSWORD` as `ENCRYPTED_PASSWORD`, and the four Kafka passwords as
|
|
their `ENCRYPTED_KAFKA_*` forms). Reads return the ciphertext, base64-encoded, which `KMS.Decrypt` turns back into
|
|
the password. A missing key, or none configured, fails the create or update with `GlueEncryptionException`, the error
|
|
`CreateConnection` and `UpdateConnection` list for a failed encryption operation. Connections created before the setting
|
|
was switched on keep their plaintext: the developer guide ("Encrypting connection passwords") states that whether a
|
|
password is encrypted "was determined when the connection was created or updated", so the setting is not applied
|
|
retroactively.
|
|
|
|
#### Security configurations
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateSecurityConfiguration | Creates a named security configuration. |
|
|
| GetSecurityConfiguration | Returns a named security configuration. |
|
|
| GetSecurityConfigurations | Lists stored security configurations with `MaxResults` (1 to 200) and `NextToken` pagination, scoped to the account and region. |
|
|
| DeleteSecurityConfiguration | Deletes a named security configuration. |
|
|
|
|
#### Jobs
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateJob | Creates a new job definition. |
|
|
| GetJob | Retrieves an existing job definition. |
|
|
| GetJobs | Retrieves all current job definitions. |
|
|
| ListJobs | Lists job names, optionally only those carrying every given tag. |
|
|
| BatchGetJobs | Retrieves several job definitions by name and reports the names not found. |
|
|
| UpdateJob | Updates an existing job definition. |
|
|
| DeleteJob | Deletes a specified job definition and its runs. |
|
|
| StartJobRun | Starts a run of a job, with per-run arguments and capacity overrides. |
|
|
| GetJobRun | Retrieves one run of a job. |
|
|
| GetJobRuns | Lists a job's runs, newest first. |
|
|
| BatchStopJobRun | Stops running runs of a job and reports the rest in `Errors`. |
|
|
|
|
By default job runs do not execute the job's script (see [Running Spark job scripts](#running-spark-job-scripts)). A run follows Glue's state machine and response shape: it
|
|
takes the job's worker type, worker count, timeout and Glue version unless the request overrides them,
|
|
and `MaxConcurrentRuns` (1 when unset) rejects a start with `ConcurrentRunsExceededException` unless
|
|
`JobRunQueuingEnabled` is set. With the default `job-run-duration-seconds` of 0 a run is `SUCCEEDED` as
|
|
soon as it starts. A positive value keeps each run `RUNNING` for that many seconds, so a test can observe
|
|
`BatchStopJobRun` (the run ends `STOPPED`) and the concurrency limit; a run whose duration exceeds the job
|
|
timeout ends `TIMEOUT` when the timeout is reached. Queued runs are admitted straight away rather than
|
|
waiting in `WAITING`.
|
|
|
|
#### Running Spark job scripts
|
|
|
|
With `FLOCI_SERVICES_GLUE_RUNNER_MODE=docker`, `StartJobRun` runs the script of a Spark job (`Command.Name` `glueetl`) whose
|
|
`ScriptLocation` is in S3, with `spark-submit` in a container of AWS's Glue 5.0 image, which holds the Glue ETL library. The
|
|
script gets the job's `DefaultArguments` with the run's `Arguments` over them, plus `--JOB_NAME` and `--JOB_RUN_ID`, so
|
|
`awsglue.utils.getResolvedOptions` reads them. Its AWS calls reach Floci with the credentials of the job's `Role`.
|
|
|
|
The run is `RUNNING` while the script runs (or `WAITING` while `JobRunQueuingEnabled` is set and `MaxConcurrentRuns` is in use,
|
|
starting once a slot frees), then `SUCCEEDED` when it exits with 0 or `FAILED` with an `ErrorMessage` when it does not or cannot
|
|
start; `TIMEOUT` when the job's `Timeout` passes; `STOPPED` after `BatchStopJobRun`. Python shell, streaming and Ray jobs, and
|
|
jobs whose script is not in S3, keep the simulation above. The image is large (AWS asks for at least 7 GB of disk) and needs a
|
|
Docker daemon (explicitly mount `/var/run/docker.sock` when running Floci in a container or Testcontainers wrapper with
|
|
`FLOCI_SERVICES_GLUE_RUNNER_MODE=docker`), which is why the mode is off by default. When the Docker daemon is unreachable at
|
|
start, runs fall back to the simulation above; if Docker fails mid-run or Floci restarts while a run is executing or waiting,
|
|
the run is `FAILED`.
|
|
|
|
#### Crawlers
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateCrawler | Creates a new crawler with specified targets, role, configuration, and optional schedule. |
|
|
| GetCrawler | Retrieves metadata for a specified crawler. |
|
|
| GetCrawlers | Retrieves metadata for all crawlers defined in the customer account. |
|
|
| ListCrawlers | Lists crawler names, optionally only those carrying every given tag. |
|
|
| BatchGetCrawlers | Retrieves several crawlers by name and reports the names not found. |
|
|
| UpdateCrawler | Updates a crawler; refused with `CrawlerRunningException` while a crawl runs. |
|
|
| DeleteCrawler | Removes a crawler and its crawl history; refused with `CrawlerRunningException` while a crawl runs. |
|
|
| StartCrawler | Starts a crawl. |
|
|
| StopCrawler | Stops the running crawl, which is then recorded as `CANCELLED`. |
|
|
| GetCrawlerMetrics | Reports time left, last and median runtime for the named crawlers, or for all of them. |
|
|
| UpdateCrawlerSchedule | Replaces a crawler's cron schedule. |
|
|
| StartCrawlerSchedule | Sets a crawler's schedule to `SCHEDULED`. |
|
|
| StopCrawlerSchedule | Sets a crawler's schedule to `NOT_SCHEDULED`. |
|
|
|
|
Crawls do not read the data store or write tables. A crawl follows the crawler's state machine:
|
|
`GetCrawler` reports `RUNNING` with `CrawlElapsedTime` while it runs, then `READY` with a `LastCrawl`
|
|
of `SUCCEEDED` (or `CANCELLED` after `StopCrawler`). With the default `crawler-run-duration-seconds` of
|
|
0 a crawl finishes as soon as it starts; a positive value keeps the crawler `RUNNING` that long.
|
|
`GetCrawlerMetrics` reports zero tables created, updated and deleted. Schedules are stored and their
|
|
state can be switched, but a schedule never starts a crawl on its own.
|
|
|
|
#### Triggers
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateTrigger | Creates an `ON_DEMAND`, `SCHEDULED` or `CONDITIONAL` trigger whose actions start jobs or crawlers. |
|
|
| GetTrigger | Retrieves a trigger. |
|
|
| GetTriggers | Retrieves triggers; with `DependentJobName`, those that start the job, or all when none do. |
|
|
| ListTriggers | Lists trigger names, with the same `DependentJobName` rule and an optional tag filter. |
|
|
| BatchGetTriggers | Retrieves several triggers by name and reports the names not found. |
|
|
| UpdateTrigger | Applies the members a `TriggerUpdate` sets and returns the trigger. |
|
|
| DeleteTrigger | Deletes a trigger; deleting one that does not exist succeeds. |
|
|
| StartTrigger | Runs an `ON_DEMAND` trigger's actions now, or activates a `SCHEDULED` or `CONDITIONAL` one. |
|
|
| StopTrigger | Deactivates a `SCHEDULED` or `CONDITIONAL` trigger. |
|
|
|
|
An activated `CONDITIONAL` trigger fires for each job run or crawl its predicate watches that finishes
|
|
in the named state (`ANY` on each matching completion, `AND` on a matching completion once every
|
|
condition's latest outcome matches). Runs finished before the trigger was activated do not count.
|
|
Floci evaluates conditional triggers after each request that starts, stops or reads job runs or crawls,
|
|
so with the default run durations of 0 a whole chain of triggers completes within the request that
|
|
starts it; with a positive duration the trigger fires on the first such request after the watched run
|
|
finishes. One request runs at most 25 firing rounds; a longer chain continues on the next such request.
|
|
As an emulator safeguard (AWS has no such limit), triggers start at most 100 runs on behalf of the run
|
|
that set off a chain, the one no trigger started, so a loop of triggers of any shape stops there.
|
|
A run a trigger starts carries its `TriggerName`. `SCHEDULED` triggers are stored and can
|
|
be activated, but no timer fires them. A trigger can belong to a workflow through `WorkflowName`, and an
|
|
`EVENT` trigger must; `EVENT` triggers are stored, but no EventBridge event starts them.
|
|
|
|
#### Workflows
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateWorkflow | Creates a workflow, with default run properties and an optional `MaxConcurrentRuns`. |
|
|
| GetWorkflow | Retrieves a workflow with its `LastRun`, and with `IncludeGraph` its graph of trigger, job and crawler nodes. |
|
|
| ListWorkflows | Lists workflow names. |
|
|
| BatchGetWorkflows | Retrieves several workflows by name and reports the names not found. |
|
|
| UpdateWorkflow | Applies the members the request sets. |
|
|
| DeleteWorkflow | Deletes a workflow and its runs; its triggers are kept. Deleting one that does not exist succeeds. |
|
|
| StartWorkflowRun | Starts a run: the workflow's starting triggers fire inside it. |
|
|
| StopWorkflowRun | Stops a running workflow run and what is running in it. |
|
|
| ResumeWorkflowRun | Starts chosen job and crawler nodes of a finished run again in a new run, and what follows them. |
|
|
| GetWorkflowRun | Retrieves a run with its `Statistics`, and with `IncludeGraph` the job runs and crawls of each node. |
|
|
| GetWorkflowRuns | Lists a workflow's runs, newest first. |
|
|
| GetWorkflowRunProperties | Retrieves a run's properties. |
|
|
| PutWorkflowRunProperties | Adds properties to a run, replacing any with the same name. |
|
|
|
|
`StartWorkflowRun` fires the workflow's starting triggers (every trigger of the workflow that is not
|
|
`CONDITIONAL`) inside a new run, with the default run properties overlaid by the request's. A
|
|
workflow's activated `CONDITIONAL` triggers fire only on job runs and crawls of a running run of that
|
|
workflow, evaluate `AND` within that run, and start their actions inside it; job runs in a workflow run
|
|
get the `--WORKFLOW_NAME` and `--WORKFLOW_RUN_ID` arguments. A run is `COMPLETED` once nothing is
|
|
running in it and nothing more fires. An action that cannot be launched (its job at its concurrency limit,
|
|
its crawler already running) is reported in the run's `ErrorMessage`, and a run none of whose starting
|
|
actions could launch ends `ERROR`. `ResumeWorkflowRun` starts each chosen job with the arguments it had in
|
|
the original run; if a node cannot be launched (its job at its concurrency limit, its crawler running) the
|
|
request fails before anything starts.
|
|
Blueprints are not emulated.
|
|
|
|
#### Classifiers
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateClassifier | Creates a Grok, XML, JSON, or CSV classifier. |
|
|
| GetClassifier | Retrieves a classifier by name. |
|
|
| GetClassifiers | Lists classifiers, paged by `MaxResults` and `NextToken`. |
|
|
| UpdateClassifier | Partially updates a classifier without changing its type. |
|
|
| DeleteClassifier | Deletes a classifier by name. |
|
|
|
|
#### Data quality rulesets
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateDataQualityRuleset | Stores a named DQDL ruleset, optionally with a `TargetTable` and tags. |
|
|
| GetDataQualityRuleset | Returns a ruleset with its `CreatedOn` and `LastModifiedOn`. |
|
|
| UpdateDataQualityRuleset | Replaces the `Description` or `Ruleset` the request sets and keeps the rest. |
|
|
| DeleteDataQualityRuleset | Deletes a ruleset and its tags. |
|
|
| ListDataQualityRulesets | Lists rulesets in name order with `RuleCount`, filtered by `Filter` (name, description, target table, created and last modified times) and `Tags`, paged by `MaxResults` (1 to 1000) and `NextToken`. |
|
|
|
|
Rulesets are stored, not evaluated: there are no recommendation or evaluation runs, so
|
|
`RecommendationRunId` is never set. `RuleCount` is the number of entries in the ruleset's
|
|
top level `Rules = [ ... ]` list, with a composite rule counted once. Rulesets are tagged by
|
|
ARN `arn:aws:glue:<region>:<account>:dataQualityRuleset/<name>`.
|
|
|
|
### Schema Registry
|
|
|
|
#### Registries
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateRegistry | Creates a schema registry. |
|
|
| GetRegistry | Returns a stored schema registry. |
|
|
| ListRegistries | Lists schema registries. |
|
|
| UpdateRegistry | Updates a schema registry's stored metadata. |
|
|
| DeleteRegistry | Deletes a schema registry. |
|
|
|
|
#### Schemas
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| CreateSchema | Creates a schema in a registry with the supplied data format and compatibility mode. |
|
|
| GetSchema | Returns a stored schema. |
|
|
| ListSchemas | Lists schemas in a registry. |
|
|
| UpdateSchema | Updates schema metadata or compatibility settings. |
|
|
| DeleteSchema | Deletes a schema from a registry. |
|
|
|
|
#### Versions
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| RegisterSchemaVersion | Registers a new schema version definition. |
|
|
| GetSchemaByDefinition | Finds a schema version that matches a supplied definition. |
|
|
| GetSchemaVersion | Returns a stored schema version. |
|
|
| ListSchemaVersions | Lists versions for a schema. |
|
|
| DeleteSchemaVersions | Deletes schema versions from a schema. |
|
|
| GetSchemaVersionsDiff | Returns the diff between two schema version numbers. |
|
|
| CheckSchemaVersionValidity | Validates a schema definition for the supplied data format. |
|
|
|
|
#### Metadata and Tags
|
|
|
|
| Action | Description |
|
|
|--------|-------------|
|
|
| PutSchemaVersionMetadata | Adds metadata to a schema version. |
|
|
| RemoveSchemaVersionMetadata | Removes metadata from a schema version. |
|
|
| QuerySchemaVersionMetadata | Returns metadata stored for matching schema versions. |
|
|
| TagResource | Adds tags to a Glue schema registry resource. |
|
|
| UntagResource | Removes tags from a Glue schema registry resource. |
|
|
| GetTags | Returns tags stored for a Glue schema registry resource. |
|
|
|
|
Supported schema formats are `AVRO`, `JSON`, and `PROTOBUF`. Compatibility modes are `NONE`, `DISABLED`, `BACKWARD`, `BACKWARD_ALL`, `FORWARD`, `FORWARD_ALL`, `FULL`, and `FULL_ALL`.
|
|
|
|
## Iceberg REST endpoint
|
|
|
|
Floci serves AWS Glue's [Iceberg REST endpoint](https://docs.aws.amazon.com/glue/latest/dg/connect-glu-iceberg-rest.html) at `/iceberg` on the Floci endpoint (`https://glue.<region>.amazonaws.com/iceberg` on AWS), signed for the `glue` service. An Iceberg REST catalog client (Spark's `SparkCatalog` with `type=rest`, PyIceberg, Trino) uses it as it uses AWS's: the warehouse is the account id, and the path prefix is `/v1/catalogs/{catalog}`, where `{catalog}` is `:` (the caller's default catalog) or the caller's account id.
|
|
|
|
```python
|
|
spark = (SparkSession.builder
|
|
.config("spark.sql.catalog.glue", "org.apache.iceberg.spark.SparkCatalog")
|
|
.config("spark.sql.catalog.glue.type", "rest")
|
|
.config("spark.sql.catalog.glue.uri", "http://localhost:4566/iceberg")
|
|
.config("spark.sql.catalog.glue.warehouse", "000000000000")
|
|
.config("spark.sql.catalog.glue.rest.sigv4-enabled", "true")
|
|
.config("spark.sql.catalog.glue.rest.signing-name", "glue")
|
|
.getOrCreate())
|
|
```
|
|
|
|
The operations are the twelve AWS lists: `GetConfig`, `ListNamespaces`, `CreateNamespace`, `LoadNamespaceMetadata`, `UpdateNamespaceProperties`, `DeleteNamespace`, `ListTables`, `CreateTable`, `LoadTable`, `TableExists`, `UpdateTable` and `DeleteTable`. A namespace is a Glue database (single-level, as on AWS); its `location` and `comment` properties are the database's `LocationUri` and `Description`. A table is a Glue table whose `Parameters.table_type` is `ICEBERG` and whose `Parameters.metadata_location` names its current metadata file in S3. The writer writes data files and manifests itself. Each commit checks the request's requirements, applies its updates, writes the next metadata file beside the last one (`<location>/metadata/00001-<uuid>.metadata.json`), and moves `metadata_location` to it, with `previous_metadata_location` set to the old one. If the Glue table changed since the commit's base, the commit is refused with `CommitFailedException` (409). A commit that fails after writing its metadata file (Glue refuses it, or it was not the last commit) removes that file again. Because every commit lands on the Glue table, Spark's `GlueCatalog` and Athena read each committed snapshot. A staged create (`stage-create`) creates nothing until its commit (`assert-create`), the way Spark and DuckDB create tables. A table with no location takes its namespace's location plus its name. `DeleteTable` drops the Glue table and leaves its files in S3.
|
|
|
|
[Athena](athena.md#iceberg-tables) creates and writes Iceberg tables through this endpoint: its query engine attaches it with a bearer token Floci issues for one statement, acting as the calling account in its Region.
|
|
|
|
A table bucket federated from Amazon S3 Tables (see [Catalogs and Amazon S3 Tables](#catalogs-and-amazon-s3-tables)) is a catalog of this endpoint too: the warehouse `<account>:s3tablescatalog/<bucket>` configures the prefix `catalogs/<account>:s3tablescatalog:<bucket>` (levels joined by `:`, as AWS's route table writes nested catalogs; `s3tablescatalog:<bucket>` names the caller's own). Its namespaces and tables are the bucket's: S3 Tables decides where a table lives, so a create names no location (a staged create already creates the table, empty, at its warehouse location), namespaces take no properties (Spark's `owner` is let go), no commit moves a table out of its warehouse, each commit moves the table's metadata location with S3 Tables' version token (a stale one answering `CommitFailedException`), a table a staged create holds is listed only once committed, and dropping a table deletes its warehouse, data and all, as S3 Tables' `DeleteTable` does.
|
|
|
|
Under IAM enforcement, each route is checked as the Glue operation AWS's [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/iceberg-rest-apis.html) documents it as, its IAM action and CloudTrail event: `GetConfig` as `glue:GetCatalog`, `ListNamespaces` and `LoadNamespaceMetadata` as `glue:GetDatabase`, `CreateNamespace` as `glue:CreateDatabase`, `UpdateNamespaceProperties` as `glue:UpdateDatabase`, `DeleteNamespace` as `glue:DeleteDatabase`, `ListTables` as `glue:GetTables`, `CreateTable` as `glue:CreateTable`, `LoadTable` and `TableExists` as `glue:GetTable`, `UpdateTable` as `glue:UpdateTable`, and `DeleteTable` as `glue:DeleteTable`. Each is checked on the account's Data Catalog, `arn:aws:glue:<region>:<account>:catalog`, whichever catalog the prefix names: nothing AWS publishes says which Glue member an Iceberg path's prefix, namespace or table fills, so a grant or a deny scoped to a federated catalog, a database or a table does not apply on this endpoint. A Glue member a caller adds to an Iceberg request's body, such as `DatabaseInput` or `Tags`, is not read either: it names no resource and gives no condition key a value. Lake Formation permissions are not checked. The token Floci's own query engine attaches with is not checked again, Athena having checked its caller.
|
|
|
|
Not yet: Other accounts' catalogs are not served. DuckDB signs SigV4 catalog requests only over HTTPS, so DuckDB attaches this endpoint with SigV4 only when Floci serves TLS (`floci.tls.enabled`).
|
|
|
|
## Catalogs and Amazon S3 Tables
|
|
|
|
`CreateCatalog`, `GetCatalog`, `GetCatalogs`, `UpdateCatalog` and `DeleteCatalog` manage catalogs beside the account's default one. Integrating table buckets with AWS analytics services creates the federated catalog `s3tablescatalog`:
|
|
|
|
```bash
|
|
aws glue create-catalog --cli-input-json '{"Name":"s3tablescatalog","CatalogInput":{"FederatedCatalog":{"Identifier":"arn:aws:s3tables:us-east-1:000000000000:bucket/*","ConnectionName":"aws:s3tables"},"AllowFullTableExternalDataAccess":"True"}}'
|
|
```
|
|
|
|
Each table bucket of the account is then a child catalog, `s3tablescatalog/<bucket>` (or `<account>:s3tablescatalog/<bucket>`), listed by `GetCatalogs` with `ParentCatalogId` `s3tablescatalog`, whose `FederatedCatalog.Identifier` is the bucket's ARN. With that `CatalogId`, `GetDatabases` and `GetDatabase` answer the bucket's namespaces, and `GetTables` and `GetTable` its tables, read from S3 Tables: Iceberg tables whose `metadata_location` and columns come from the table's current metadata file. A table without metadata yet has neither. Catalog ids answer as `<account>:<catalog>[/<child>]`. Writing through a federated catalog with Glue's own API (`CreateDatabase`, `CreateTable` with its `CatalogId`) and a federated catalog's IAM resources are not served yet; the [Iceberg REST endpoint](#iceberg-rest-endpoint) writes to its tables.
|
|
|
|
## Configuration
|
|
|
|
| Variable | Default | Description |
|
|
|---|---|---|
|
|
| `FLOCI_SERVICES_GLUE_ENABLED` | `true` | Enable or disable the service |
|
|
| `FLOCI_SERVICES_GLUE_JOB_RUN_DURATION_SECONDS` | `0` | Seconds a job run stays `RUNNING` before it succeeds; `0` finishes it as soon as it starts |
|
|
| `FLOCI_SERVICES_GLUE_RUNNER_MODE` | `immediate` | `docker` runs the script of a `glueetl` job in a container; `immediate` runs no script |
|
|
| `FLOCI_SERVICES_GLUE_IMAGE` | `public.ecr.aws/glue/aws-glue-libs:5` | The image a `docker` job run uses |
|
|
| `FLOCI_SERVICES_GLUE_DOCKER_NETWORK` | | Docker network for the job containers; unset uses the global default |
|
|
| `FLOCI_SERVICES_GLUE_CRAWLER_RUN_DURATION_SECONDS` | `0` | Seconds a crawl keeps the crawler `RUNNING` before it succeeds; `0` finishes it as soon as it starts |
|
|
|
|
## Integration with Athena
|
|
|
|
The Glue Data Catalog is automatically used by **Athena** to resolve table names to S3 locations and formats. When you submit an Athena query, Floci reads all Glue tables for the target database and generates DuckDB views on top of the underlying S3 objects before executing the SQL.
|
|
|
|
Tables can reference a Schema Registry schema version through `StorageDescriptor.SchemaReference`. On `GetTable` and `GetTables`, Floci resolves the schema definition into Glue columns when possible.
|
|
|
|
A table whose `Parameters.table_type` is `ICEBERG` (case-insensitive), as set by `pyiceberg`'s `GlueCatalog` and AWS's own Glue-Iceberg integration, is read via `iceberg_scan` against `Parameters.metadata_location` instead, following the table's real manifest list rather than its `StorageDescriptor`. See [Athena's format inference](athena.md#format-inference) for the full explanation.
|
|
|
|
For every other table, the DuckDB read function is selected based on the table's `StorageDescriptor.InputFormat` and `StorageDescriptor.SerdeInfo.SerializationLibrary`:
|
|
|
|
| Condition | DuckDB function |
|
|
|---|---|
|
|
| `InputFormat` or `SerializationLibrary` contains `parquet` | `read_parquet` |
|
|
| `InputFormat` or `SerializationLibrary` contains `json` | `read_json_auto` |
|
|
| `InputFormat` contains `hive` | `read_json_auto` |
|
|
| Anything else | `read_csv_auto` |
|
|
|
|
## Data Catalog Example
|
|
|
|
```bash
|
|
export AWS_ENDPOINT_URL=http://localhost:4566
|
|
|
|
# Create a database
|
|
aws glue create-database \
|
|
--database-input '{"Name": "analytics"}' \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
|
|
# Create a JSON table (standard AWS format for NDJSON data)
|
|
aws glue create-table \
|
|
--database-name analytics \
|
|
--table-input '{
|
|
"Name": "orders",
|
|
"StorageDescriptor": {
|
|
"Location": "s3://my-bucket/orders/",
|
|
"InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
|
|
"OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
|
|
"SerdeInfo": {
|
|
"SerializationLibrary": "org.openx.data.jsonserde.JsonSerDe"
|
|
},
|
|
"Columns": [
|
|
{"Name": "id", "Type": "int"},
|
|
{"Name": "amount", "Type": "double"}
|
|
]
|
|
}
|
|
}' \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
|
|
# Create a Parquet table
|
|
aws glue create-table \
|
|
--database-name analytics \
|
|
--table-input '{
|
|
"Name": "events",
|
|
"StorageDescriptor": {
|
|
"Location": "s3://my-bucket/events/",
|
|
"InputFormat": "org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat",
|
|
"SerdeInfo": {
|
|
"SerializationLibrary": "org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe"
|
|
},
|
|
"Columns": [
|
|
{"Name": "event_id", "Type": "string"},
|
|
{"Name": "ts", "Type": "bigint"}
|
|
]
|
|
}
|
|
}' \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
```
|
|
|
|
## Schema Registry Example
|
|
|
|
```bash
|
|
export AWS_ENDPOINT_URL=http://localhost:4566
|
|
|
|
cat > /tmp/order.avsc <<'JSON'
|
|
{"type":"record","name":"Order","namespace":"example","fields":[{"name":"id","type":"long"}]}
|
|
JSON
|
|
|
|
cat > /tmp/order-v2.avsc <<'JSON'
|
|
{"type":"record","name":"Order","namespace":"example","fields":[{"name":"id","type":"long"},{"name":"amount","type":["null","double"],"default":null}]}
|
|
JSON
|
|
|
|
aws glue create-registry \
|
|
--registry-name local-registry \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
|
|
aws glue create-schema \
|
|
--registry-id RegistryName=local-registry \
|
|
--schema-name orders \
|
|
--data-format AVRO \
|
|
--compatibility BACKWARD \
|
|
--schema-definition file:///tmp/order.avsc \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
|
|
aws glue register-schema-version \
|
|
--schema-id RegistryName=local-registry,SchemaName=orders \
|
|
--schema-definition file:///tmp/order-v2.avsc \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
|
|
aws glue list-schema-versions \
|
|
--schema-id RegistryName=local-registry,SchemaName=orders \
|
|
--endpoint-url $AWS_ENDPOINT_URL
|
|
```
|
|
|
|
Catalog pagination for GetDatabases, GetTables, GetPartitions and GetTableVersions uses opaque continuation cursors ordered by database name, table name, partition values and descending version number respectively. Removing the last returned item or inserting items before its cursor does not invalidate continuation. Table schema references are resolved for the selected page.
|