-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationmainThis is an issue that is considered v0.5.0 maintenance and should be merged into mainThis is an issue that is considered v0.5.0 maintenance and should be merged into mainv0.6-devDenotes that the issue is meant to be merged into the v0.6-beta development branch.Denotes that the issue is meant to be merged into the v0.6-beta development branch.
Milestone
Description
Example code:
attribute_names = [row.attribute_name for row in sedona.sql(f"""
SELECT DISTINCT(attribute_name) FROM local.db.location_attributes
""").collect()]
attribute_names_sql = ", ".join([f"'{name}'" for name in attribute_names])
sedona.sql(f"""
CREATE OR REPLACE TEMP VIEW locations_view AS (
WITH location_attributes_pivot AS (
SELECT *
FROM (
SELECT location_id, attribute_name, value
FROM local.db.location_attributes
) src
PIVOT (
max(value) FOR attribute_name IN ({attribute_names_sql})
)
)
SELECT l.id, l.name, ST_GeomFromWKB(l.geometry) AS geometry, la.*
FROM local.db.locations l
LEFT JOIN location_attributes_pivot la
ON l.id = la.location_id
WHERE l.id IS NOT NULL
AND la.location_id IS NOT NULL
)
""")
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationmainThis is an issue that is considered v0.5.0 maintenance and should be merged into mainThis is an issue that is considered v0.5.0 maintenance and should be merged into mainv0.6-devDenotes that the issue is meant to be merged into the v0.6-beta development branch.Denotes that the issue is meant to be merged into the v0.6-beta development branch.