Skip to content

Commit 4b9df27

Browse files
committed
fix tests
1 parent 408c53c commit 4b9df27

24 files changed

+333
-150
lines changed

ruff.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ ignore = []
6363
fixable = ["ALL"]
6464
unfixable = []
6565

66+
per-file-ignores = {}
67+
6668
# Allow unused variables when underscore-prefixed.
6769
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
6870

69-
[lint.per-file-ignores]
70-
"tests/integration/test_inspect_table.py" = ["E501"]
71-
"tests/io/test_pyarrow.py" = ["E501"]
72-
7371
[lint.pyupgrade]
7472
# Preserve types, even if a file imports `from __future__ import annotations`.
7573
keep-runtime-typing = true

tests/catalog/test_hive.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,10 @@ def test_rename_table_to_namespace_does_not_exists() -> None:
970970

971971
catalog._client = MagicMock()
972972
catalog._client.__enter__().alter_table_with_environment_context.side_effect = InvalidOperationException(
973-
message="Unable to change partition or table. Database default does not exist Check metastore logs for detailed stack.does_not_exists" # noqa: E501
973+
message=(
974+
"Unable to change partition or table. Database default does not exist "
975+
"Check metastore logs for detailed stack.does_not_exists"
976+
)
974977
)
975978

976979
with pytest.raises(NoSuchNamespaceError) as exc_info:

tests/catalog/test_rest.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ def test_no_uri_supplied() -> None:
156156

157157

158158
@pytest.mark.filterwarnings(
159-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
159+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
160+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
160161
)
161162
def test_token_200(rest_mock: Mocker) -> None:
162163
rest_mock.post(
@@ -179,7 +180,8 @@ def test_token_200(rest_mock: Mocker) -> None:
179180

180181

181182
@pytest.mark.filterwarnings(
182-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
183+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
184+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
183185
)
184186
def test_token_200_without_optional_fields(rest_mock: Mocker) -> None:
185187
rest_mock.post(
@@ -198,7 +200,8 @@ def test_token_200_without_optional_fields(rest_mock: Mocker) -> None:
198200

199201

200202
@pytest.mark.filterwarnings(
201-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
203+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
204+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
202205
)
203206
def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None:
204207
mock_request = rest_mock.post(
@@ -223,7 +226,8 @@ def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None:
223226

224227

225228
@pytest.mark.filterwarnings(
226-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
229+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
230+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
227231
)
228232
def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None:
229233
mock_request = rest_mock.post(
@@ -246,7 +250,8 @@ def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None:
246250

247251

248252
@pytest.mark.filterwarnings(
249-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
253+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
254+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
250255
)
251256
def test_token_with_default_scope(rest_mock: Mocker) -> None:
252257
mock_request = rest_mock.post(
@@ -267,7 +272,8 @@ def test_token_with_default_scope(rest_mock: Mocker) -> None:
267272

268273

269274
@pytest.mark.filterwarnings(
270-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
275+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
276+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
271277
)
272278
def test_token_with_custom_scope(rest_mock: Mocker) -> None:
273279
mock_request = rest_mock.post(
@@ -289,7 +295,8 @@ def test_token_with_custom_scope(rest_mock: Mocker) -> None:
289295

290296

291297
@pytest.mark.filterwarnings(
292-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
298+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
299+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
293300
)
294301
def test_token_200_w_oauth2_server_uri(rest_mock: Mocker) -> None:
295302
rest_mock.post(
@@ -314,7 +321,8 @@ def test_token_200_w_oauth2_server_uri(rest_mock: Mocker) -> None:
314321

315322

316323
@pytest.mark.filterwarnings(
317-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
324+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
325+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
318326
)
319327
def test_config_200(requests_mock: Mocker) -> None:
320328
requests_mock.get(
@@ -402,7 +410,8 @@ def test_config_sets_headers(requests_mock: Mocker) -> None:
402410

403411

404412
@pytest.mark.filterwarnings(
405-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
413+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
414+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
406415
)
407416
def test_token_400(rest_mock: Mocker) -> None:
408417
rest_mock.post(
@@ -418,7 +427,8 @@ def test_token_400(rest_mock: Mocker) -> None:
418427

419428

420429
@pytest.mark.filterwarnings(
421-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
430+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
431+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
422432
)
423433
def test_token_401(rest_mock: Mocker) -> None:
424434
message = "invalid_client"
@@ -664,7 +674,8 @@ def test_list_namespace_with_parent_404(rest_mock: Mocker) -> None:
664674

665675

666676
@pytest.mark.filterwarnings(
667-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
677+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
678+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
668679
)
669680
@pytest.mark.parametrize("status_code", [401, 419])
670681
def test_list_namespaces_token_expired_success_on_retries(rest_mock: Mocker, status_code: int) -> None:
@@ -2017,7 +2028,8 @@ def test_custom_namespace_separator(rest_mock: Mocker) -> None:
20172028

20182029

20192030
@pytest.mark.filterwarnings(
2020-
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" # noqa: E501
2031+
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. "
2032+
"Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
20212033
)
20222034
def test_auth_header(rest_mock: Mocker) -> None:
20232035
mock_request = rest_mock.post(

tests/cli/test_console.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,10 @@ def test_json_schema(catalog: InMemoryCatalog) -> None:
627627
runner = CliRunner()
628628
result = runner.invoke(run, ["--output=json", "schema", "default.my_table"])
629629
assert result.exit_code == 0
630-
assert (
631-
result.output
632-
== """{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},{"id":3,"name":"z","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]}\n""" # noqa: E501
630+
assert result.output == (
631+
'{"type":"struct","fields":[{"id":1,"name":"x","type":"long","required":true},'
632+
'{"id":2,"name":"y","type":"long","required":true,"doc":"comment"},'
633+
'{"id":3,"name":"z","type":"long","required":true}],"schema-id":0,"identifier-field-ids":[]}\n'
633634
)
634635

635636

@@ -819,9 +820,8 @@ def test_json_properties_get_table_specific_property_that_doesnt_exist(catalog:
819820
runner = CliRunner()
820821
result = runner.invoke(run, ["--output=json", "properties", "get", "table", "default.my_table", "doesnotexist"])
821822
assert result.exit_code == 1
822-
assert (
823-
result.output
824-
== """{"type": "NoSuchPropertyException", "message": "Could not find property doesnotexist on table default.my_table"}\n""" # noqa: E501
823+
assert result.output == (
824+
'{"type": "NoSuchPropertyException", "message": "Could not find property doesnotexist on table default.my_table"}\n'
825825
)
826826

827827

tests/conftest.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,10 @@ def metadata_location_gz(tmp_path_factory: pytest.TempPathFactory) -> str:
11881188
"status": 1,
11891189
"snapshot_id": 8744736658442914487,
11901190
"data_file": {
1191-
"file_path": "/home/iceberg/warehouse/nyc/taxis_partitioned/data/VendorID=null/00000-633-d8a4223e-dc97-45a1-86e1-adaba6e8abd7-00001.parquet", # noqa: E501
1191+
"file_path": (
1192+
"/home/iceberg/warehouse/nyc/taxis_partitioned/data/VendorID=null/"
1193+
"00000-633-d8a4223e-dc97-45a1-86e1-adaba6e8abd7-00001.parquet"
1194+
),
11921195
"file_format": "PARQUET",
11931196
"partition": {"VendorID": 1, "tpep_pickup_day": 1925},
11941197
"record_count": 19513,
@@ -1308,7 +1311,10 @@ def metadata_location_gz(tmp_path_factory: pytest.TempPathFactory) -> str:
13081311
"status": 1,
13091312
"snapshot_id": 8744736658442914487,
13101313
"data_file": {
1311-
"file_path": "/home/iceberg/warehouse/nyc/taxis_partitioned/data/VendorID=1/00000-633-d8a4223e-dc97-45a1-86e1-adaba6e8abd7-00002.parquet", # noqa: E501
1314+
"file_path": (
1315+
"/home/iceberg/warehouse/nyc/taxis_partitioned/data/VendorID=1/"
1316+
"00000-633-d8a4223e-dc97-45a1-86e1-adaba6e8abd7-00002.parquet"
1317+
),
13121318
"file_format": "PARQUET",
13131319
"partition": {"VendorID": 1, "tpep_pickup_datetime": None},
13141320
"record_count": 95050,
@@ -2146,7 +2152,10 @@ def adls_fsspec_fileio(request: pytest.FixtureRequest) -> Generator[FsspecFileIO
21462152
azurite_url = request.config.getoption("--adls.endpoint")
21472153
azurite_account_name = request.config.getoption("--adls.account-name")
21482154
azurite_account_key = request.config.getoption("--adls.account-key")
2149-
azurite_connection_string = f"DefaultEndpointsProtocol=http;AccountName={azurite_account_name};AccountKey={azurite_account_key};BlobEndpoint={azurite_url}/{azurite_account_name};" # noqa: E501
2155+
azurite_connection_string = (
2156+
f"DefaultEndpointsProtocol=http;AccountName={azurite_account_name};"
2157+
f"AccountKey={azurite_account_key};BlobEndpoint={azurite_url}/{azurite_account_name};"
2158+
)
21502159
properties = {
21512160
"adls.connection-string": azurite_connection_string,
21522161
"adls.account-name": azurite_account_name,
@@ -2183,7 +2192,10 @@ def pyarrow_fileio_adls(request: pytest.FixtureRequest) -> Generator[Any, None,
21832192

21842193
azurite_account_name = request.config.getoption("--adls.account-name")
21852194
azurite_account_key = request.config.getoption("--adls.account-key")
2186-
azurite_connection_string = f"DefaultEndpointsProtocol=http;AccountName={azurite_account_name};AccountKey={azurite_account_key};BlobEndpoint={azurite_url}/{azurite_account_name};" # noqa: E501
2195+
azurite_connection_string = (
2196+
f"DefaultEndpointsProtocol=http;AccountName={azurite_account_name};"
2197+
f"AccountKey={azurite_account_key};BlobEndpoint={azurite_url}/{azurite_account_name};"
2198+
)
21872199
properties = {
21882200
ADLS_ACCOUNT_NAME: azurite_account_name,
21892201
ADLS_ACCOUNT_KEY: azurite_account_key,
@@ -2623,7 +2635,8 @@ def spark() -> "SparkSession":
26232635
# Not supported by Spark
26242636
# 'time': [time(1, 22, 0), None, time(19, 25, 0)],
26252637
# Not natively supported by Arrow
2626-
# 'uuid': [uuid.UUID('00000000-0000-0000-0000-000000000000').bytes, None, uuid.UUID('11111111-1111-1111-1111-111111111111').bytes], # noqa: E501
2638+
# 'uuid': [uuid.UUID('00000000-0000-0000-0000-000000000000').bytes, None,
2639+
# uuid.UUID('11111111-1111-1111-1111-111111111111').bytes],
26272640
"binary": [b"\01", None, b"\22"],
26282641
"fixed": [
26292642
uuid.UUID("00000000-0000-0000-0000-000000000000").bytes,
@@ -2676,7 +2689,8 @@ def arrow_table_with_null(pa_schema: "pa.Schema") -> "pa.Table":
26762689
"long": [1, None, 9],
26772690
"float": [0.0, None, 0.9],
26782691
"double": [0.0, None, 0.9],
2679-
# 'time': [1_000_000, None, 3_000_000], # Example times: 1s, none, and 3s past midnight #Spark does not support time fields # noqa: E501
2692+
# 'time': [1_000_000, None, 3_000_000], # Example times: 1s, none, and 3s past midnight
2693+
# Spark does not support time fields
26802694
"timestamp": [datetime(2023, 1, 1, 19, 25, 00), None, datetime(2023, 3, 1, 19, 25, 00)],
26812695
"timestamptz": [
26822696
datetime(2023, 1, 1, 19, 25, 00, tzinfo=timezone.utc),
@@ -2687,7 +2701,8 @@ def arrow_table_with_null(pa_schema: "pa.Schema") -> "pa.Table":
26872701
# Not supported by Spark
26882702
# 'time': [time(1, 22, 0), None, time(19, 25, 0)],
26892703
# Not natively supported by Arrow
2690-
# 'uuid': [uuid.UUID('00000000-0000-0000-0000-000000000000').bytes, None, uuid.UUID('11111111-1111-1111-1111-111111111111').bytes], # noqa: E501
2704+
# 'uuid': [uuid.UUID('00000000-0000-0000-0000-000000000000').bytes, None,
2705+
# uuid.UUID('11111111-1111-1111-1111-111111111111').bytes],
26912706
"binary": [b"\01", None, b"\22"],
26922707
"fixed": [
26932708
uuid.UUID("00000000-0000-0000-0000-000000000000").bytes,

tests/expressions/test_evaluator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,9 @@ def test_strict_integer_in(strict_data_file_schema: Schema, strict_data_file_1:
14271427

14281428

14291429
def test_strict_integer_not_in(strict_data_file_schema: Schema, strict_data_file_1: DataFile) -> None:
1430-
# should_read = _StrictMetricsEvaluator(strict_data_file_schema, NotIn("id", {INT_MIN_VALUE - 25, INT_MIN_VALUE - 24})).eval(strict_data_file_1) # noqa: E501
1430+
# should_read = _StrictMetricsEvaluator(
1431+
# strict_data_file_schema, NotIn("id", {INT_MIN_VALUE - 25, INT_MIN_VALUE - 24})
1432+
# ).eval(strict_data_file_1)
14311433
# assert should_read, "Should match: all values != 5 and != 6"
14321434

14331435
should_read = _StrictMetricsEvaluator(strict_data_file_schema, NotIn("id", {INT_MIN_VALUE - 1, INT_MIN_VALUE})).eval(

tests/expressions/test_visitors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,10 @@ def test_bind_visitor_already_bound(table_schema_simple: Schema) -> None:
261261
with pytest.raises(TypeError) as exc_info:
262262
visit(bound, visitor=BindVisitor(schema=table_schema_simple, case_sensitive=True))
263263
assert (
264-
"Found already bound predicate: BoundEqualTo(term=BoundReference(field=NestedField(field_id=1, name='foo', field_type=StringType(), required=False), accessor=Accessor(position=0,inner=None)), literal=literal('hello'))" # noqa: E501
265-
== str(exc_info.value)
266-
)
264+
"Found already bound predicate: BoundEqualTo(term=BoundReference("
265+
"field=NestedField(field_id=1, name='foo', field_type=StringType(), required=False), "
266+
"accessor=Accessor(position=0,inner=None)), literal=literal('hello'))"
267+
) == str(exc_info.value)
267268

268269

269270
def test_visit_bound_visitor_unknown_predicate() -> None:

tests/integration/test_add_files.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ def test_add_files_to_bucket_partitioned_table_fails(spark: SparkSession, sessio
470470
with pytest.raises(ValueError) as exc_info:
471471
tbl.add_files(file_paths=file_paths)
472472
assert (
473-
"Cannot infer partition value from parquet metadata for a non-linear Partition Field: baz_bucket_3 with transform bucket[3]" # noqa: E501
474-
in str(exc_info.value)
473+
"Cannot infer partition value from parquet metadata for a non-linear Partition Field: "
474+
"baz_bucket_3 with transform bucket[3]" in str(exc_info.value)
475475
)
476476

477477

@@ -518,8 +518,8 @@ def test_add_files_to_partitioned_table_fails_with_lower_and_upper_mismatch(
518518
with pytest.raises(ValueError) as exc_info:
519519
tbl.add_files(file_paths=file_paths)
520520
assert (
521-
"Cannot infer partition value from parquet metadata as there are more than one partition values for Partition Field: baz. lower_value=123, upper_value=124" # noqa: E501
522-
in str(exc_info.value)
521+
"Cannot infer partition value from parquet metadata as there are more than one partition values "
522+
"for Partition Field: baz. lower_value=123, upper_value=124" in str(exc_info.value)
523523
)
524524

525525

@@ -754,8 +754,8 @@ def test_add_files_with_timestamp_tz_ns_fails(session_catalog: Catalog, format_v
754754
exception_cause = exc_info.value.__cause__
755755
assert isinstance(exception_cause, TypeError)
756756
assert (
757-
"Iceberg does not yet support 'ns' timestamp precision. Use 'downcast-ns-timestamp-to-us-on-write' configuration property to automatically downcast 'ns' to 'us' on write." # noqa: E501
758-
in exception_cause.args[0]
757+
"Iceberg does not yet support 'ns' timestamp precision. Use 'downcast-ns-timestamp-to-us-on-write' "
758+
"configuration property to automatically downcast 'ns' to 'us' on write." in exception_cause.args[0]
759759
)
760760

761761

tests/integration/test_inspect_table.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,13 +1096,22 @@ def test_inspect_files_format_version_3(spark: SparkSession, session_catalog: Ca
10961096
},
10971097
)
10981098

1099-
# fmt: off
1099+
row1 = (
1100+
"(false, 'a', 'aaaaaaaaaaaaaaaaaaaaaa', 1, 1, 0.0, 0.0, "
1101+
"TIMESTAMP('2023-01-01 19:25:00'), TIMESTAMP('2023-01-01 19:25:00+00:00'), "
1102+
"DATE('2023-01-01'), X'01', X'00000000000000000000000000000000')"
1103+
)
1104+
row2 = "(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"
1105+
row3 = (
1106+
"(true, 'z', 'zzzzzzzzzzzzzzzzzzzzzz', 9, 9, 0.9, 0.9, "
1107+
"TIMESTAMP('2023-03-01 19:25:00'), TIMESTAMP('2023-03-01 19:25:00+00:00'), "
1108+
"DATE('2023-03-01'), X'12', X'11111111111111111111111111111111')"
1109+
)
11001110
insert_data_sql = f"""INSERT INTO {identifier} VALUES
1101-
(false, 'a', 'aaaaaaaaaaaaaaaaaaaaaa', 1, 1, 0.0, 0.0, TIMESTAMP('2023-01-01 19:25:00'), TIMESTAMP('2023-01-01 19:25:00+00:00'), DATE('2023-01-01'), X'01', X'00000000000000000000000000000000'),
1102-
(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
1103-
(true, 'z', 'zzzzzzzzzzzzzzzzzzzzzz', 9, 9, 0.9, 0.9, TIMESTAMP('2023-03-01 19:25:00'), TIMESTAMP('2023-03-01 19:25:00+00:00'), DATE('2023-03-01'), X'12', X'11111111111111111111111111111111');
1111+
{row1},
1112+
{row2},
1113+
{row3};
11041114
"""
1105-
# fmt: on
11061115

11071116
spark.sql(insert_data_sql)
11081117
spark.sql(insert_data_sql)

0 commit comments

Comments
 (0)