Skip to content

Commit

Permalink
fix(data-warehouse): Revert how we read delta s3 wrapped tables (#24352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert09 authored Aug 13, 2024
1 parent 64718d5 commit fdc2ac7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 17 additions & 17 deletions posthog/hogql/database/s3_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,32 @@ def return_expr(expr: str) -> str:
return f"{substitute_params(expr, raw_params)})"

# DeltaS3Wrapper format
if format == "DeltaS3Wrapper":
if url.endswith("/"):
escaped_url = add_param(f"{url}*.zstd.parquet")
else:
escaped_url = add_param(f"{url}/*.zstd.parquet")
# if format == "DeltaS3Wrapper":
# if url.endswith("/"):
# escaped_url = add_param(f"{url}*.zstd.parquet")
# else:
# escaped_url = add_param(f"{url}/*.zstd.parquet")

if structure:
escaped_structure = add_param(structure, False)
# if structure:
# escaped_structure = add_param(structure, False)

expr = f"s3({escaped_url}"
# expr = f"s3({escaped_url}"

if access_key and access_secret:
escaped_access_key = add_param(access_key)
escaped_access_secret = add_param(access_secret)
# if access_key and access_secret:
# escaped_access_key = add_param(access_key)
# escaped_access_secret = add_param(access_secret)

expr += f", {escaped_access_key}, {escaped_access_secret}"
# expr += f", {escaped_access_key}, {escaped_access_secret}"

expr += ", 'Parquet'"
# expr += ", 'Parquet'"

if structure:
expr += f", {escaped_structure}"
# if structure:
# expr += f", {escaped_structure}"

return return_expr(expr)
# return return_expr(expr)

# Delta format
if format == "Delta":
if format == "Delta" or format == "DeltaS3Wrapper":
escaped_url = add_param(url)
if structure:
escaped_structure = add_param(structure, False)
Expand Down
34 changes: 17 additions & 17 deletions posthog/hogql/database/test/test_s3_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,23 @@ def test_s3_build_function_call_without_context_and_delta_format(self):
res = build_function_call("http://url.com", DataWarehouseTable.TableFormat.Delta, "key", "secret", None, None)
assert res == "deltaLake('http://url.com', 'key', 'secret')"

def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format(self):
res = build_function_call(
"http://url.com", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", None, None
)
assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet')"

def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format_with_slash(self):
res = build_function_call(
"http://url.com/", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", None, None
)
assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet')"

def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format_with_structure(self):
res = build_function_call(
"http://url.com/", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", "some structure", None
)
assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet', 'some structure')"
# def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format(self):
# res = build_function_call(
# "http://url.com", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", None, None
# )
# assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet')"

# def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format_with_slash(self):
# res = build_function_call(
# "http://url.com/", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", None, None
# )
# assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet')"

# def test_s3_build_function_call_without_context_and_deltaS3Wrapper_format_with_structure(self):
# res = build_function_call(
# "http://url.com/", DataWarehouseTable.TableFormat.DeltaS3Wrapper, "key", "secret", "some structure", None
# )
# assert res == "s3('http://url.com/*.zstd.parquet', 'key', 'secret', 'Parquet', 'some structure')"

def test_s3_build_function_call_without_context_and_delta_format_and_with_structure(self):
res = build_function_call(
Expand Down

0 comments on commit fdc2ac7

Please sign in to comment.