This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch branch-0.1.0 in repository https://gitbox.apache.org/repos/asf/sedona-db.git
commit 579b9d5e95b241243f164fed2d6b145d771b7dce Author: Kelly-Ann Dolor <[email protected]> AuthorDate: Tue Sep 23 23:28:47 2025 -0700 [DOCS] ix-mobile-nav-sedonadb-923 (#143) --- docs/stylesheets/extra.css | 28 +++++++------ docs/working-with-sql-sedonadb.md | 83 +++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 4 +- 3 files changed, 102 insertions(+), 13 deletions(-) diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index f017b44..5cd0bcf 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -107,18 +107,22 @@ Swap Logo ONLY in Mobile Navigation ========================================================================== */ -/* 1. Hide the default logo image inside the mobile nav */ -.md-nav--primary .md-nav__title .md-logo img { - display: none; -} - -/* 2. Apply the new mobile logo as a background image */ -.md-nav--primary .md-nav__title .md-logo { - display: block; - height: 48px; /* Adjust size as needed */ - width: 100%; - background-image: url('../image/sedona_logo_symbol_white.svg'); /* IMPORTANT: Update this path */ +/* + Target the logo link (<a> tag) directly and apply the new logo + as a background image, overriding the theme's default icon. +*/ +.md-sidebar--primary .md-nav__title a.md-nav__button.md-logo { + background-image: url('/docs/image/sedona_logo_symbol.svg'); background-size: contain; background-repeat: no-repeat; - background-position: center left; + background-position: center; + + /* Hide the theme's default icon which is applied via a mask */ + -webkit-mask: none; + mask: none; +} + +/* Change the mobile nav header label text to white */ +label.md-nav__title { + color: #FFFFFF !important; } diff --git a/docs/working-with-sql-sedonadb.md b/docs/working-with-sql-sedonadb.md new file mode 100644 index 0000000..84bd354 --- /dev/null +++ b/docs/working-with-sql-sedonadb.md @@ -0,0 +1,83 @@ +<!--- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Working with SQL in SedonaDB + +This page details several nuances of using SQL in SedonaDB. + +## Creating Arrays of Spatial Types in SQL + +When constructing an array of spatial objects (like `ST_POINT`) in SedonaDB, you must use bracket notation `[...]` instead of the standard `ARRAY()` function. + +### The Incorrect Method: `ARRAY()` + +Attempting to use the `ARRAY()` function to create an array of spatial types is not supported and will result in a planning error. SedonaDB will not recognize `ARRAY` as a valid function for this operation. + +```python title="Example (Fails)" +>>> sd.sql("SELECT ARRAY(ST_POINT(1,2), ST_POINT(3,4))") +... +Error during planning: Invalid function 'array' +``` + +### The Correct Method: Brackets + +To correctly build an array, enclose your comma-separated spatial objects in **square brackets `[]`**. This syntax +successfully creates a list containing the spatial data structures. + +```python title="Example (Works)" +>>> sd.sql("SELECT [ST_POINT(1,2), ST_POINT(3,4)]").show() +┌──────────────────────────────────────────────────────────────────────────────────────────┐ +│ make_array(st_point(Int64(1),Int64(2)),st_point(Int64(3),Int64(4))) │ +│ list │ +╞══════════════════════════════════════════════════════════════════════════════════════════╡ +│ [0101000000000000000000f03f0000000000000040, 010100000000000000000008400000000000001040] │ +└──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +This approach correctly instructs SedonaDB to construct an array containing the two `ST_POINT` objects. + +## Temporary Views Not Supported in SQL + +SedonaDB does not support the `CREATE TEMP VIEW` or `CREATE TEMPORARY VIEW` SQL commands. Executing these statements will result in an error. + +Attempting to create a temporary view directly with `sd.sql()` will fail, as shown below. + +```python title="Unsupported Example" +>>> sd.sql("CREATE TEMP VIEW b AS SELECT * FROM '/path/to/building.parquet'") +Traceback (most recent call last): + ... +sedonadb._lib.SedonaError: Temporary views not supported +``` + +### Recommended Alternative + +The correct way to create a view is to load your data and use `to_view()`. + +This approach provides the same functionality and is the standard practice in Spark-based environments. + +```python title="Working Example" +# Step 1: Load your data into a DataFrame first +>>> building_df = sd.read_parquet("/path/to/building.parquet") + +# Step 2: Register the DataFrame as a temporary view +>>> building_df.to_view("b") + +# Step 3: You can now successfully query the view using SQL +>>> sd.sql("SELECT * FROM b LIMIT 5").show() +``` diff --git a/mkdocs.yml b/mkdocs.yml index 6b8babe..60a56b1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -54,8 +54,10 @@ nav: - Working with GeoPandas: geopandas-interop.md - Working with Overture: overture-examples.md - Working with Parquet Files: working-with-parquet-files.md - - Contributors Guide: contributors-guide.md - Joining Spatial Data with Different Coordinate Systems: crs-examples.md + - Working with SQL in SedonaDB: working-with-sql-sedonadb.md + - Contributors Guide: contributors-guide.md + - <<: *community_links # This becomes the 'SedonaDB Reference' tab
