Skip to content
Merged
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
7 changes: 4 additions & 3 deletions splitgraph/hooks/data_source/fdw.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ def _preview_table(self, schema: str, table: str, limit: int = 10) -> List[Dict[
result_json = cast(
List[Dict[str, Any]],
self.engine.run_sql(
SQL("SELECT row_to_json(t.*) FROM {}.{} t LIMIT %s").format(
Identifier(schema), Identifier(table)
),
SQL(
"WITH p AS MATERIALIZED(SELECT * FROM {}.{} LIMIT %s) "
"SELECT row_to_json(p.*) FROM p"
).format(Identifier(schema), Identifier(table)),
(limit,),
return_shape=ResultShape.MANY_ONE,
),
Expand Down
4 changes: 4 additions & 0 deletions test/splitgraph/ingestion/test_socrata.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,7 @@ def test_socrata_data_source_introspection_smoke(local_engine_empty):
schema, params = result["some_table"]
assert len(schema) > 1
assert params == {"socrata_id": "8wbx-tsch"}

preview_result = data_source.preview(tables=result)
assert len(preview_result["some_table"]) == 10
assert preview_result["some_table"][0][":id"] is not None