-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Glue Exporter and related #6823
Merged
Merged
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
c1cc898
glue client lua docs
Isan-Rivkin 15b7545
symlink exporter docs
Isan-Rivkin ffb4f3d
added export hooks full docs
Isan-Rivkin 82be2e9
fixes
Isan-Rivkin 02875d3
fixes
Isan-Rivkin 94f8225
fixes
Isan-Rivkin 2b401b9
tab fixes
Isan-Rivkin d0098c8
indent
Isan-Rivkin f5bef53
update glue exporter
Isan-Rivkin c91bd6b
initial tutorial
Isan-Rivkin cad6acc
Added docs
Isan-Rivkin 8351cae
fix link
Isan-Rivkin 3d5cb91
update docs
Isan-Rivkin 3776994
fix broken anchors
Isan-Rivkin 4d6b01b
fix redirects
Isan-Rivkin 0e0bc71
fix docs
Isan-Rivkin d09808d
WIP
Isan-Rivkin ad41921
pending
Isan-Rivkin 3a8638b
added table
Isan-Rivkin 2d65f56
indent
Isan-Rivkin bc062be
fix link
Isan-Rivkin 296f31f
Add imag
Isan-Rivkin 34b6699
docs
Isan-Rivkin 1399999
update location
Isan-Rivkin 01aed58
fix infinite loop redirect
Isan-Rivkin 6729b4e
final examples of scripts
Isan-Rivkin b666433
final docs
Isan-Rivkin f3f4502
final
Isan-Rivkin deab3f2
Update docs/howto/catalog_exports.md
Isan-Rivkin 0c896f4
Update docs/howto/catalog_exports.md
Isan-Rivkin 232b781
Update docs/howto/catalog_exports.md
Isan-Rivkin ac70832
fix partial comments
Isan-Rivkin d6f0e31
Update docs/integrations/glue_metastore.md
Isan-Rivkin a38480a
Update docs/integrations/glue_metastore.md
Isan-Rivkin 3a5788c
Update docs/integrations/glue_metastore.md
Isan-Rivkin 0ae1d76
Update docs/howto/catalog_exports.md
Isan-Rivkin d000484
Update docs/howto/catalog_exports.md
Isan-Rivkin f5f4406
Update docs/howto/catalog_exports.md
Isan-Rivkin 2bb6fc6
Update docs/howto/catalog_exports.md
Isan-Rivkin ac45af7
Update docs/howto/catalog_exports.md
Isan-Rivkin 51b14a0
comments review fixes
Isan-Rivkin 6559100
update fixes
Isan-Rivkin 6719ba5
Update docs/integrations/glue_metastore.md
Isan-Rivkin f8c337d
Update docs/integrations/glue_metastore.md
Isan-Rivkin 6d4a022
Update docs/integrations/glue_metastore.md
Isan-Rivkin 9200b8a
fixes
Isan-Rivkin 0265cb9
fix
Isan-Rivkin a0c0cc9
remove example
Isan-Rivkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
title: Data Catalogs Export | ||
description: This section explains how lakeFS can integrate with external Data Catalogs via metastore update operations. | ||
parent: How-To | ||
--- | ||
|
||
# Data Catalogs Export | ||
|
||
{% include toc_2-3.html %} | ||
|
||
## About Data Catalogs Export | ||
|
||
Data Catalog Export is all about integrating query engines (like Spark, AWS Athena, Presto, etc.) with lakeFS. | ||
|
||
Data Catalogs (such as Hive Metastore or AWS Glue) store metadata for services (such as Spark, Trino and Athena). They contain metadata such as the location of the table, information about columns, partitions and much more. | ||
|
||
With Data Catalog Exports, one can leverage the versioning capabilities of lakeFS in external data warehouses and query engines to access tables with branches and commits. | ||
|
||
At the end of this guide, you will be able to query lakeFS data from Athena, Trino and other catalog-dependent tools: | ||
|
||
```sql | ||
USE main; | ||
USE my_branch; -- any branch | ||
USE v101; -- or tag | ||
|
||
SELECT * FROM users | ||
INNER JOIN events | ||
ON users.id = events.user_id; -- SQL stays the same, branch or tag exist as schema | ||
``` | ||
|
||
## How it works | ||
|
||
Several well known formats exist today let you export existing tables in lakeFS into a "native" object store representation | ||
which does not require copying the data outside of lakeFS. | ||
|
||
These are metadata representations and can be applied automatically through hooks. | ||
|
||
### Table Decleration | ||
|
||
After creating a lakeFS repository, configure tables as table descriptor objects on the repository on the path `_lakefs_tables/TABLE.yaml`. | ||
Note: the Glue exporter can currently only export tables of `type: hive`. We expect to add more. | ||
|
||
#### Hive tables | ||
|
||
Hive metadata server tables are essentially just a set of objects that share a prefix, with no table metadata stored on the object store. You need to configure prefix, partitions, and schema. | ||
|
||
```yaml | ||
name: animals | ||
type: hive | ||
path: path/to/animals/ | ||
partition_columns: ['year'] | ||
schema: | ||
type: struct | ||
fields: | ||
- name: year | ||
type: integer | ||
nullable: false | ||
metadata: {} | ||
- name: page | ||
type: string | ||
nullable: false | ||
metadata: {} | ||
- name: site | ||
type: string | ||
nullable: true | ||
metadata: | ||
comment: a comment about this column | ||
``` | ||
|
||
Useful types recognized by Hive include `integer`, `long`, `short`, `string`, `double`, `float`, `date`, and `timestamp`. | ||
{: .note } | ||
|
||
### Catalog Exporters | ||
|
||
Exporters are code packages accessible through [Lua integration]({% link howto/hooks/lua.md %}#lua-library-reference). Each exporter is exposed as a Lua function under the package namespace `lakefs/catalogexport`. Call them from hooks to connect lakeFS tables to various catalogs. | ||
|
||
#### Currently supported exporters | ||
|
||
- Symlink Exporter: Writes metadata for the table using Hive's [SymlinkTextInputFormat](https://svn.apache.org/repos/infra/websites/production/hive/content/javadocs/r2.1.1/api/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.html) | ||
- AWS Glue Catalog (+ Athena) Exporter: Creates a table in Glue using Hive's format and updates the location to symlink files (reuses Symlink Exporter). | ||
- See a step by step guide on how to integrate with [Glue Exporter]({% link integrations/glue_metastore.md %}) | ||
|
||
#### Running an Exporter | ||
|
||
Exporters are meant to run as [Lua hooks]({% link howto/hooks/lua.md %}). | ||
|
||
Configure the actions trigger by using [events and branches]({% link howto/hooks/index.md %}#action-file-schema). Of course, you can add additional custom filtering logic to the Lua script if needed. | ||
The default table name when exported is `${repository_id}_${_lakefs_tables/TABLE.md(name field)}_${ref_name}_${short_commit}`. | ||
|
||
Example of an action that will be triggered when a `post-commit` event happens in the `export_table` branch. | ||
|
||
```yaml | ||
name: Glue Table Exporter | ||
description: export my table to glue | ||
on: | ||
post-commit: | ||
branches: ["export_table"] | ||
hooks: | ||
- id: my_exporter | ||
type: lua | ||
properties: | ||
# exporter script location | ||
script_path: "scripts/my_export_script.lua" | ||
args: | ||
# table descriptor | ||
table_source: '_lakefs_tables/my_table.yaml' | ||
``` | ||
|
||
Tip: Actions can be extended to customize any desired behavior, for example validating branch names since they are part of the table name: | ||
|
||
```yaml | ||
# _lakefs_actions/validate_branch_name.yaml | ||
name: validate-lower-case-branches | ||
on: | ||
pre-create-branch: | ||
hooks: | ||
- id: check_branch_id | ||
type: lua | ||
properties: | ||
script: | | ||
regexp = require("regexp") | ||
if not regexp.match("^[a-z0-9\\_\\-]+$", action.branch_id) then | ||
error("branches must be lower case, invalid branch ID: " .. action.branch_id) | ||
end | ||
``` | ||
|
||
### Flow | ||
|
||
The following diagram demonstrates what happens when a lakeFS Action triggers runs a lua hook that calls an exporter. | ||
|
||
```mermaid | ||
sequenceDiagram | ||
note over Lua Hook: lakeFS Action trigger. <br> Pass Context for the export. | ||
Lua Hook->>Exporter: export request | ||
note over Table Registry: _lakefs_tables/TABLE.yaml | ||
Exporter->>Table Registry: Get table descriptor | ||
Table Registry->>Exporter: Parse table structure | ||
Exporter->>Object Store: materialize an exported table | ||
Exporter->>Catalog: register object store location | ||
Query Engine-->Catalog: Query | ||
Query Engine-->Object Store: Query | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we already define "hive tables" in our docs elsewhere. Can we unify these definitions? (Fine to open an issue to do this in a future PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: #6863
You're right but the current definition is so slim 1 sentence and an example so I prefer not to unify this currently since it's really a per-case definition.
I'll open an issue because I prefer to have a more mature and organized definition when doing that and not ad-hoc in this PR.