Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class CatalogDeclarativeDataSource(Base):
client_id: str | None = None
authentication_type: str | None = None
alternative_data_source_id: str | None = None
date_time_semantics: str | None = None

def to_test_request(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CatalogDataSourceBase(Base):
"type",
"schema",
"alternative_data_source_id",
"date_time_semantics",
]

id: str
Expand All @@ -61,6 +62,7 @@ class CatalogDataSourceBase(Base):
decoded_parameters: list[dict[str, str]] | None = None
credentials: Credentials = field(repr=False)
alternative_data_source_id: str | None = None
date_time_semantics: str | None = None

@type.validator # type: ignore
def _check_allowed_values(self, attribute: Attribute, value: str) -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- br, gzip, deflate
X-GDC-VALIDATE-RELATIONS:
- 'true'
X-Requested-With:
- XMLHttpRequest
method: GET
uri: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
response:
body:
string:
data:
attributes:
alternativeDataSourceId: ds-put-abc-id
authenticationType: USERNAME_PASSWORD
name: demo-test-ds
schema: demo
type: POSTGRESQL
url: jdbc:postgresql://postgres:5432/tiger?sslmode=prefer
username: postgres
id: demo-test-ds
type: dataSource
links:
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
headers:
Content-Type:
- application/json
DATE: &id001
- PLACEHOLDER
Expires:
- '0'
Pragma:
- no-cache
X-Content-Type-Options:
- nosniff
X-GDC-TRACE-ID: *id001
status:
code: 200
message: OK
- request:
body:
data:
attributes:
dateTimeSemantics: LOCAL
type: POSTGRESQL
url: jdbc:postgresql://postgres:5432/tiger?sslmode=prefer
id: demo-test-ds
type: dataSource
headers:
Accept:
- application/json
Accept-Encoding:
- br, gzip, deflate
Content-Type:
- application/json
X-GDC-VALIDATE-RELATIONS:
- 'true'
X-Requested-With:
- XMLHttpRequest
method: PATCH
uri: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
response:
body:
string:
detail: Date time semantics setting is not supported for the given database
type
status: 400
title: Bad Request
traceId: NORMALIZED_TRACE_ID_000000000000
headers:
Content-Type:
- application/problem+json
DATE: *id001
Expires:
- '0'
Pragma:
- no-cache
X-Content-Type-Options:
- nosniff
X-GDC-TRACE-ID: *id001
status:
code: 400
message: Bad Request
- request:
body:
dataSources:
- alternativeDataSourceId: ds-put-abc-id
id: demo-test-ds
name: demo-test-ds
password: passw0rd
permissions:
- assignee:
id: demo2
type: user
name: MANAGE
- assignee:
id: demoGroup
type: userGroup
name: USE
schema: demo
type: POSTGRESQL
url: jdbc:postgresql://postgres:5432/tiger?sslmode=prefer
username: postgres
headers:
Accept-Encoding:
- br, gzip, deflate
Content-Type:
- application/json
X-GDC-VALIDATE-RELATIONS:
- 'true'
X-Requested-With:
- XMLHttpRequest
method: PUT
uri: http://localhost:3000/api/v1/layout/dataSources
response:
body:
string: ''
headers:
DATE: *id001
Expires:
- '0'
Pragma:
- no-cache
X-Content-Type-Options:
- nosniff
X-GDC-TRACE-ID: *id001
status:
code: 204
message: No Content
version: 1
48 changes: 48 additions & 0 deletions packages/gooddata-sdk/tests/catalog/test_catalog_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,54 @@ def token_from_file_side_effect(file_path: Union[str, Path], base64_encode: bool
# snapshot_data_sources fixture also restores in teardown


def test_date_time_semantics():
"""Unit test: date_time_semantics round-trips through SDK models.

dateTimeSemantics is only supported for StarRocks/AI Lakehouse backends, so
this test validates SDK-level serialization and deserialization without hitting
the real API.
"""
# 1. Deserialization: CatalogDataSource.from_api populates date_time_semantics
entity = {
"id": "test-ds",
"type": "dataSource",
"attributes": {
"name": "test-ds",
"type": "POSTGRESQL",
"schema": "demo",
"url": "jdbc:postgresql://localhost:5432/demo",
"date_time_semantics": "LOCAL",
},
}
ds = CatalogDataSource.from_api(entity)
assert ds.date_time_semantics == "LOCAL"

# 2. Absent by default when not present in the API response
entity_no_dts = {
"id": "test-ds",
"type": "dataSource",
"attributes": {
"name": "test-ds",
"type": "POSTGRESQL",
"schema": "demo",
"url": "jdbc:postgresql://localhost:5432/demo",
},
}
ds_no_dts = CatalogDataSource.from_api(entity_no_dts)
assert ds_no_dts.date_time_semantics is None

# 3. Serialization: to_api_patch includes date_time_semantics in the PATCH body
patch_doc = CatalogDataSource.to_api_patch(
"test-ds",
{
"date_time_semantics": "LOCAL",
"type": "POSTGRESQL",
"url": "jdbc:postgresql://localhost:5432/demo",
},
)
assert patch_doc.data.attributes.date_time_semantics == "LOCAL"


@gd_vcr.use_cassette(str(_fixtures_dir / "demo_test_scan_model.yaml"))
def test_scan_model(test_config):
sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])
Expand Down
Loading
Loading