-
Notifications
You must be signed in to change notification settings - Fork 7
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
BSE-4358: Python S3 Table support #96
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
379e560
Add basic support for s3 tables in python
IsaacWarren 7a9b85c
Add read tests
IsaacWarren 092ef4e
Add write test
IsaacWarren 1436bdf
Update docs
IsaacWarren 0358d15
[Run CI]
IsaacWarren dda2fbf
Fix arn
IsaacWarren 8e9fada
[Run CI]
IsaacWarren a15c236
Fix comment [run ci]
IsaacWarren a4c8571
Increase aws session length
IsaacWarren 749403b
[Run CI]
IsaacWarren 7f08458
Only set AWS_SESSION_TOKEN temporarily
IsaacWarren 4376bcd
[Run CI]
IsaacWarren 2521c20
Merge remote-tracking branch 'origin/main' into isaac/s3tables
IsaacWarren cdce77b
Relock [run ci]
IsaacWarren 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
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
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,132 @@ | ||
import random | ||
import string | ||
from io import StringIO | ||
|
||
import boto3 | ||
import pandas as pd | ||
import pytest | ||
|
||
import bodo | ||
from bodo.tests.user_logging_utils import ( | ||
check_logger_msg, | ||
create_string_io_logger, | ||
set_logging_stream, | ||
) | ||
from bodo.tests.utils import ( | ||
_get_dist_arg, | ||
check_func, | ||
run_rank0, | ||
temp_env_override, | ||
) | ||
|
||
pytest_mark = pytest.mark.iceberg | ||
|
||
bucket_arn = "arn:aws:s3tables:us-east-2:427443013497:bucket/unittest-bucket" | ||
|
||
|
||
@temp_env_override({"AWS_REGION": "us-east-2"}) | ||
def test_basic_read(memory_leak_check): | ||
""" | ||
Test reading a complete Iceberg table S3 Tables | ||
""" | ||
|
||
def impl(table_name, conn, db_schema): | ||
return pd.read_sql_table(table_name, conn, db_schema) | ||
|
||
py_out = pd.DataFrame( | ||
{ | ||
"A": ["ally", "bob", "cassie", "david", None], | ||
"B": [10.5, -124.0, 11.11, 456.2, -8e2], | ||
"C": [True, None, False, None, None], | ||
} | ||
) | ||
|
||
conn = "iceberg+" + bucket_arn | ||
check_func( | ||
impl, | ||
("bodo_iceberg_read_test", conn, "read_namespace"), | ||
py_output=py_out, | ||
sort_output=True, | ||
reset_index=True, | ||
) | ||
|
||
|
||
@temp_env_override({"AWS_REGION": "us-east-2"}) | ||
def test_read_implicit_pruning(memory_leak_check): | ||
""" | ||
Test reading an Iceberg table from S3 Tables with Bodo | ||
compiler column pruning | ||
""" | ||
|
||
def impl(table_name, conn, db_schema): | ||
df = pd.read_sql_table(table_name, conn, db_schema) | ||
df["B"] = df["B"].abs() | ||
return df[["B", "A"]] | ||
|
||
py_out = pd.DataFrame( | ||
{ | ||
"B": [10.5, 124.0, 11.11, 456.2, 8e2], | ||
"A": ["ally", "bob", "cassie", "david", None], | ||
} | ||
) | ||
|
||
conn = "iceberg+" + bucket_arn | ||
stream = StringIO() | ||
logger = create_string_io_logger(stream) | ||
with set_logging_stream(logger, 1): | ||
check_func( | ||
impl, | ||
("bodo_iceberg_read_test", conn, "read_namespace"), | ||
py_output=py_out, | ||
sort_output=True, | ||
reset_index=True, | ||
) | ||
check_logger_msg(stream, "Columns loaded ['A', 'B']") | ||
|
||
|
||
@temp_env_override({"AWS_REGION": "us-east-2"}) | ||
@temp_env_override({"AWS_DEFAULT_REGION": "us-east-2"}) | ||
def test_basic_write(memory_leak_check): | ||
""" | ||
Test writing a complete Iceberg table to S3 Tables | ||
""" | ||
|
||
@bodo.jit(distributed=["df"]) | ||
def write(df, table_name, conn, db_schema): | ||
df.to_sql(table_name, conn, db_schema) | ||
|
||
def read(table_name, conn, db_schema): | ||
return pd.read_sql_table(table_name, conn, db_schema) | ||
|
||
df = pd.DataFrame( | ||
{ | ||
"A": ["ally", "bob", "cassie", "david", None] * 5, | ||
"B": [10.5, -124.0, 11.11, 456.2, -8e2] * 5, | ||
"C": [True, None, False, None, None] * 5, | ||
} | ||
) | ||
conn = "iceberg+" + bucket_arn | ||
table_name = f"bodo_iceberg_write_test_{''.join(random.choices(string.ascii_lowercase , k=4))}" | ||
|
||
try: | ||
write(_get_dist_arg(df), table_name, conn, "write_namespace") | ||
|
||
check_func( | ||
read, | ||
(table_name, conn, "write_namespace"), | ||
py_output=df, | ||
sort_output=True, | ||
reset_index=True, | ||
) | ||
finally: | ||
|
||
def cleanup(): | ||
client = boto3.client("s3tables") | ||
client.delete_table( | ||
name=table_name, | ||
namespace="write_namespace", | ||
tableBucketARN=bucket_arn, | ||
) | ||
client.close() | ||
|
||
run_rank0(cleanup) |
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
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
13 changes: 13 additions & 0 deletions
13
...ceberg_connector/iceberg-java/src/main/java/com/bodo/iceberg/catalog/S3TablesBuilder.java
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,13 @@ | ||
package com.bodo.iceberg.catalog; | ||
|
||
import java.util.Map; | ||
import org.apache.iceberg.catalog.Catalog; | ||
import software.amazon.s3tables.iceberg.S3TablesCatalog; | ||
|
||
public class S3TablesBuilder { | ||
public static Catalog create(String connStr) { | ||
S3TablesCatalog catalog = new S3TablesCatalog(); | ||
catalog.initialize("S3Tables_catalog", Map.of("warehouse", connStr)); | ||
return catalog; | ||
} | ||
} |
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.
We don't need this anymore as AFAIK since we now create a transaction to get the write location
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.
Is this not used for read occasionally? Can we test with the E2E tests, cause its different catalogs that usually exhibit this behavior
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.
I didn't think so but will check locally since the e2e tests are broken right now
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.
Ok I tried to get the e2e tests running locally and couldn't even on main. Hadoop did pass which is the only one we don't have unittest coverage for so I think we're good
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.
Ok