Skip to content

Commit bbf84c1

Browse files
author
Ilyas Gasanov
committed
[DOP-21447] Add Parquet API schema
1 parent 601ad82 commit bbf84c1

File tree

7 files changed

+59
-6
lines changed

7 files changed

+59
-6
lines changed

syncmaster/schemas/v1/file_formats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
EXCEL_FORMAT = Literal["excel"]
99
XML_FORMAT = Literal["xml"]
1010
ORC_FORMAT = Literal["orc"]
11+
PARQUET_FORMAT = Literal["parquet"]

syncmaster/schemas/v1/transfers/file/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@
1414
XML,
1515
Excel,
1616
JSONLine,
17+
Parquet,
1718
)
1819

1920

2021
# At the moment the ReadTransferSourceParams and ReadTransferTargetParams
2122
# classes are identical but may change in the future
2223
class ReadFileTransferSource(BaseModel):
2324
directory_path: str
24-
file_format: CSV | JSONLine | JSON | Excel | XML | ORC = Field(..., discriminator="type")
25+
file_format: CSV | JSONLine | JSON | Excel | XML | ORC | Parquet = Field(..., discriminator="type")
2526
options: dict[str, Any]
2627

2728

2829
class ReadFileTransferTarget(BaseModel):
2930
directory_path: str
3031
# JSON format is not supported for writing
31-
file_format: CSV | JSONLine | Excel | XML | ORC = Field(
32+
file_format: CSV | JSONLine | Excel | XML | ORC | Parquet = Field(
3233
...,
3334
discriminator="type",
3435
)
@@ -39,7 +40,7 @@ class ReadFileTransferTarget(BaseModel):
3940
# classes are identical but may change in the future
4041
class CreateFileTransferSource(BaseModel):
4142
directory_path: str
42-
file_format: CSV | JSONLine | JSON | Excel | XML | ORC = Field(..., discriminator="type")
43+
file_format: CSV | JSONLine | JSON | Excel | XML | ORC | Parquet = Field(..., discriminator="type")
4344
options: dict[str, Any] = Field(default_factory=dict)
4445

4546
class Config:
@@ -56,7 +57,7 @@ def _directory_path_is_valid_path(cls, value):
5657
class CreateFileTransferTarget(BaseModel):
5758
directory_path: str
5859
# JSON format is not supported as a target
59-
file_format: CSV | JSONLine | Excel | XML | ORC = Field(
60+
file_format: CSV | JSONLine | Excel | XML | ORC | Parquet = Field(
6061
...,
6162
discriminator="type",
6263
)

syncmaster/schemas/v1/transfers/file_format.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
JSON_FORMAT,
1111
JSONLINE_FORMAT,
1212
ORC_FORMAT,
13+
PARQUET_FORMAT,
1314
XML_FORMAT,
1415
)
1516

@@ -50,3 +51,7 @@ class XML(BaseModel):
5051

5152
class ORC(BaseModel):
5253
type: ORC_FORMAT
54+
55+
56+
class Parquet(BaseModel):
57+
type: PARQUET_FORMAT

tests/test_unit/test_transfers/test_create_transfer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ async def test_developer_plus_can_not_create_transfer_with_target_format_json(
636636
"context": {
637637
"discriminator": "'type'",
638638
"tag": "json",
639-
"expected_tags": "'csv', 'jsonline', 'excel', 'xml', 'orc'",
639+
"expected_tags": "'csv', 'jsonline', 'excel', 'xml', 'orc', 'parquet'",
640640
},
641641
"input": {"type": "json", "lineSep": "\n", "encoding": "utf-8"},
642642
"location": ["body", "target_params", "s3", "file_format"],
643-
"message": "Input tag 'json' found using 'type' does not match any of the expected tags: 'csv', 'jsonline', 'excel', 'xml', 'orc'",
643+
"message": "Input tag 'json' found using 'type' does not match any of the expected tags: 'csv', 'jsonline', 'excel', 'xml', 'orc', 'parquet'",
644644
"code": "union_tag_invalid",
645645
},
646646
],

tests/test_unit/test_transfers/test_file_transfers/test_create_transfer.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@
7373
"some": "option",
7474
},
7575
},
76+
{
77+
"type": "s3",
78+
"directory_path": "/some/parquet/path",
79+
"file_format": {
80+
"type": "parquet",
81+
},
82+
"options": {
83+
"some": "option",
84+
},
85+
},
7686
],
7787
)
7888
async def test_developer_plus_can_create_s3_transfer(
@@ -157,6 +167,9 @@ async def test_developer_plus_can_create_s3_transfer(
157167
"orc": {
158168
"type": "orc",
159169
},
170+
"parquet": {
171+
"type": "parquet",
172+
},
160173
}
161174

162175
for params in (transfer.source_params, transfer.target_params):
@@ -211,6 +224,13 @@ async def test_developer_plus_can_create_s3_transfer(
211224
"type": "orc",
212225
},
213226
},
227+
{
228+
"type": "hdfs",
229+
"directory_path": "/some/parquet/path",
230+
"file_format": {
231+
"type": "parquet",
232+
},
233+
},
214234
],
215235
)
216236
async def test_developer_plus_can_create_hdfs_transfer(
@@ -296,6 +316,9 @@ async def test_developer_plus_can_create_hdfs_transfer(
296316
"orc": {
297317
"type": "orc",
298318
},
319+
"parquet": {
320+
"type": "parquet",
321+
},
299322
}
300323

301324
for params in (transfer.source_params, transfer.target_params):
@@ -350,6 +373,13 @@ async def test_developer_plus_can_create_hdfs_transfer(
350373
"type": "orc",
351374
},
352375
},
376+
{
377+
"type": "s3",
378+
"directory_path": "some/path",
379+
"file_format": {
380+
"type": "parquet",
381+
},
382+
},
353383
],
354384
)
355385
async def test_cannot_create_file_transfer_with_relative_path(

tests/test_unit/test_transfers/test_file_transfers/test_read_transfer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
},
5252
"options": {},
5353
},
54+
{
55+
"type": "s3",
56+
"directory_path": "/some/parquet/path",
57+
"file_format": {
58+
"type": "parquet",
59+
},
60+
"options": {},
61+
},
5462
],
5563
)
5664
@pytest.mark.parametrize(

tests/test_unit/test_transfers/test_file_transfers/test_update_transfer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
},
5252
"options": {},
5353
},
54+
{
55+
"type": "s3",
56+
"directory_path": "/some/parquet/path",
57+
"file_format": {
58+
"type": "parquet",
59+
},
60+
"options": {},
61+
},
5462
],
5563
)
5664
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)