diff --git a/README.md b/README.md index e4c329a..7671cb2 100644 --- a/README.md +++ b/README.md @@ -61,16 +61,16 @@ if res.task_id: ### Upload ```python -from altertable_lakehouse.models import UploadFormat, UploadMode +from altertable_lakehouse.models import UploadMode with open("data.csv", "rb") as f: client.upload( catalog="my_cat", schema="my_schema", table="my_table", - format=UploadFormat.CSV, mode=UploadMode.APPEND, - content=f.read() + content=f.read(), + content_type="text/csv" ) ``` diff --git a/src/altertable_lakehouse/client.py b/src/altertable_lakehouse/client.py index 1a5aed4..b1876d8 100644 --- a/src/altertable_lakehouse/client.py +++ b/src/altertable_lakehouse/client.py @@ -16,7 +16,6 @@ ValidateResponse, AutocompleteRequest, AutocompleteResponse, - UploadFormat, UploadMode, QueryMetadata, QueryResult, @@ -124,26 +123,26 @@ def upload( catalog: str, schema: str, table: str, - format: UploadFormat, - mode: UploadMode, content: bytes, + mode: Optional[UploadMode] = None, primary_key: Optional[str] = None, + content_type: str = "application/octet-stream", ) -> None: params = { "catalog": catalog, "schema": schema, "table": table, - "format": format.value, - "mode": mode.value, } + if mode is not None: + params["mode"] = mode.value if primary_key: params["primary_key"] = primary_key try: res = self._client.post( - "/upload", + "/upsert", params=params, content=content, - headers={"Content-Type": "application/octet-stream"}, + headers={"Content-Type": content_type}, ) self._check_response(res) except httpx.RequestError as e: diff --git a/src/altertable_lakehouse/models.py b/src/altertable_lakehouse/models.py index d69725e..fced3e3 100644 --- a/src/altertable_lakehouse/models.py +++ b/src/altertable_lakehouse/models.py @@ -11,12 +11,6 @@ class ComputeSize(str, Enum): XL = "XL" -class UploadFormat(str, Enum): - CSV = "csv" - JSON = "json" - PARQUET = "parquet" - - class UploadMode(str, Enum): CREATE = "create" APPEND = "append" diff --git a/tests/test_client.py b/tests/test_client.py index f59c404..00157af 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -47,7 +47,7 @@ def test_query_all(client): def test_upload(client): try: - client.upload(catalog="cat", schema="sch", table="tbl", format=models.UploadFormat.JSON, mode=models.UploadMode.APPEND, content=b'{"a":1}') + client.upload(catalog="cat", schema="sch", table="tbl", mode=models.UploadMode.APPEND, content=b'{"a":1}', content_type="application/json") except errors.BadRequestError: pass