Skip to content

Commit a5c83ad

Browse files
author
Ilyas Gasanov
committed
[DOP-21446] Add ORC API schema
1 parent 9979b0b commit a5c83ad

File tree

9 files changed

+75
-8
lines changed

9 files changed

+75
-8
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ORC API schema

syncmaster/schemas/v1/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
PostgresReadTransferSourceAndTarget,
3737
ReadDBTransfer,
3838
)
39-
from syncmaster.schemas.v1.transfers.file_format import CSV, JSON, XML, Excel, JSONLine
39+
from syncmaster.schemas.v1.transfers.file_format import (
40+
CSV,
41+
JSON,
42+
ORC,
43+
XML,
44+
Excel,
45+
JSONLine,
46+
)
4047
from syncmaster.schemas.v1.transfers.run import (
4148
CreateRunSchema,
4249
ReadRunSchema,

syncmaster/schemas/v1/file_formats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
JSON_FORMAT = Literal["json"]
88
EXCEL_FORMAT = Literal["excel"]
99
XML_FORMAT = Literal["xml"]
10+
ORC_FORMAT = Literal["orc"]

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@
77

88
from pydantic import BaseModel, Field, field_validator
99

10-
from syncmaster.schemas.v1.transfers.file_format import CSV, JSON, XML, Excel, JSONLine
10+
from syncmaster.schemas.v1.transfers.file_format import (
11+
CSV,
12+
JSON,
13+
ORC,
14+
XML,
15+
Excel,
16+
JSONLine,
17+
)
1118

1219

1320
# At the moment the ReadTransferSourceParams and ReadTransferTargetParams
1421
# classes are identical but may change in the future
1522
class ReadFileTransferSource(BaseModel):
1623
directory_path: str
17-
file_format: CSV | JSONLine | JSON | Excel | XML = Field(..., discriminator="type")
24+
file_format: CSV | JSONLine | JSON | Excel | XML | ORC = Field(..., discriminator="type")
1825
options: dict[str, Any]
1926

2027

2128
class ReadFileTransferTarget(BaseModel):
2229
directory_path: str
2330
# JSON format is not supported for writing
24-
file_format: CSV | JSONLine | Excel | XML = Field(
31+
file_format: CSV | JSONLine | Excel | XML | ORC = Field(
2532
...,
2633
discriminator="type",
2734
)
@@ -32,7 +39,7 @@ class ReadFileTransferTarget(BaseModel):
3239
# classes are identical but may change in the future
3340
class CreateFileTransferSource(BaseModel):
3441
directory_path: str
35-
file_format: CSV | JSONLine | JSON | Excel | XML = Field(..., discriminator="type")
42+
file_format: CSV | JSONLine | JSON | Excel | XML | ORC = Field(..., discriminator="type")
3643
options: dict[str, Any] = Field(default_factory=dict)
3744

3845
class Config:
@@ -49,7 +56,7 @@ def _directory_path_is_valid_path(cls, value):
4956
class CreateFileTransferTarget(BaseModel):
5057
directory_path: str
5158
# JSON format is not supported as a target
52-
file_format: CSV | JSONLine | Excel | XML = Field(
59+
file_format: CSV | JSONLine | Excel | XML | ORC = Field(
5360
...,
5461
discriminator="type",
5562
)

syncmaster/schemas/v1/transfers/file_format.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
EXCEL_FORMAT,
1010
JSON_FORMAT,
1111
JSONLINE_FORMAT,
12+
ORC_FORMAT,
1213
XML_FORMAT,
1314
)
1415

@@ -45,3 +46,7 @@ class XML(BaseModel):
4546
type: XML_FORMAT
4647
root_tag: str
4748
row_tag: str
49+
50+
51+
class ORC(BaseModel):
52+
type: ORC_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'",
639+
"expected_tags": "'csv', 'jsonline', 'excel', 'xml', 'orc'",
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'",
643+
"message": "Input tag 'json' found using 'type' does not match any of the expected tags: 'csv', 'jsonline', 'excel', 'xml', 'orc'",
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
@@ -63,6 +63,16 @@
6363
"some": "option",
6464
},
6565
},
66+
{
67+
"type": "s3",
68+
"directory_path": "/some/orc/path",
69+
"file_format": {
70+
"type": "orc",
71+
},
72+
"options": {
73+
"some": "option",
74+
},
75+
},
6676
],
6777
)
6878
async def test_developer_plus_can_create_s3_transfer(
@@ -144,6 +154,9 @@ async def test_developer_plus_can_create_s3_transfer(
144154
"root_tag": "data",
145155
"row_tag": "record",
146156
},
157+
"orc": {
158+
"type": "orc",
159+
},
147160
}
148161

149162
for params in (transfer.source_params, transfer.target_params):
@@ -191,6 +204,13 @@ async def test_developer_plus_can_create_s3_transfer(
191204
"row_tag": "record",
192205
},
193206
},
207+
{
208+
"type": "hdfs",
209+
"directory_path": "/some/orc/path",
210+
"file_format": {
211+
"type": "orc",
212+
},
213+
},
194214
],
195215
)
196216
async def test_developer_plus_can_create_hdfs_transfer(
@@ -273,6 +293,9 @@ async def test_developer_plus_can_create_hdfs_transfer(
273293
"root_tag": "data",
274294
"row_tag": "record",
275295
},
296+
"orc": {
297+
"type": "orc",
298+
},
276299
}
277300

278301
for params in (transfer.source_params, transfer.target_params):
@@ -320,6 +343,13 @@ async def test_developer_plus_can_create_hdfs_transfer(
320343
"row_tag": "record",
321344
},
322345
},
346+
{
347+
"type": "s3",
348+
"directory_path": "some/path",
349+
"file_format": {
350+
"type": "orc",
351+
},
352+
},
323353
],
324354
)
325355
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
@@ -43,6 +43,14 @@
4343
},
4444
"options": {},
4545
},
46+
{
47+
"type": "s3",
48+
"directory_path": "/some/orc/path",
49+
"file_format": {
50+
"type": "orc",
51+
},
52+
"options": {},
53+
},
4654
],
4755
)
4856
@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
@@ -43,6 +43,14 @@
4343
},
4444
"options": {},
4545
},
46+
{
47+
"type": "s3",
48+
"directory_path": "/some/orc/path",
49+
"file_format": {
50+
"type": "orc",
51+
},
52+
"options": {},
53+
},
4654
],
4755
)
4856
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)