Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set precision of TWKB to 5 and fix doc in formatters #320

Merged
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
8 changes: 8 additions & 0 deletions clouds/databricks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog for databricks cloud. All notable changes to this project will be docu

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.4] - 2022-09-15

### Changed
- The XY precission of the TWKBWriter is set to 4

### Fixed
- [formatters] Fix the doc of the transformers functions ST_ASLATLONTEXT and ST_ASTEXT.

## [1.0.3] - 2022-09-06

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class STIndexSpec extends AnyFunSpec with HiveTestEnvironment with TestTables {
|ST_CRSFROMTEXT('+proj=merc +lat_ts=56.5 +ellps=GRS80'),
|ST_CRSFROMTEXT('+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs')))""".stripMargin
)
df.head.get(0) shouldEqual "POINT (0.0000269 0.0000452)"
df.head.get(0) shouldEqual "POINT (0.00003 0.00005)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait TWKBUtils {
}

private[this] val writerPool = new ThreadLocal[TWKBWriter] {
override def initialValue = new TWKBWriter
override def initialValue = new TWKBWriter().setXYPrecision(5)
}

def read(s: String): Geometry = read(s.getBytes)
Expand Down
4 changes: 2 additions & 2 deletions clouds/databricks/modules/doc/constructors/ST_MAKEBBOX.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Creates a `Geometry` representing a bounding box with the given boundaries.
**Example**

```sql
SELECT carto.ST_ASTEXT(carto.ST_MAKEBBOX(-91.8554869, 29.5060349, -91.8382077, 29.5307334)) AS bbox;
-- POLYGON ((-91.8554869 29.5060349, -91.8554869 29.5307334, -91.8382077 29.5307334, -91.8382077 29.5060349, -91.8554869 29.5060349))
SELECT carto.ST_ASTEXT(carto.ST_MAKEBBOX(-91.85548, 29.50603, -91.83820, 29.53073)) AS bbox;
-- POLYGON ((-91.85548 29.50603, -91.85548 29.53073, -91.83820 29.53073, -91.8382 29.50603, -91.85548 29.50603))
```
4 changes: 2 additions & 2 deletions clouds/databricks/modules/doc/constructors/ST_MAKEBOX2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Creates a `Geometry` representing a bounding box defined by the given `Points`.
**Example**

```sql
SELECT carto.ST_ASTEXT(carto.ST_MAKEBOX2D(carto.ST_MAKEPOINT(-91.8554869, 29.5060349), carto.ST_MAKEPOINT(-91.8382077, 29.5307334))) AS bbox;
-- POLYGON ((-91.8554869 29.5060349, -91.8554869 29.5307334, -91.8382077 29.5307334, -91.8382077 29.5060349, -91.8554869 29.5060349))
SELECT carto.ST_ASTEXT(carto.ST_MAKEBOX2D(carto.ST_MAKEPOINT(-91.85548, 29.50603), carto.ST_MAKEPOINT(-91.83820, 29.53073))) AS bbox;
-- POLYGON ((-91.85548 29.50603, -91.85548 29.53073, -91.8382 29.53073, -91.8382 29.50603, -91.85548 29.50603))
```
4 changes: 2 additions & 2 deletions clouds/databricks/modules/doc/constructors/ST_MAKEPOINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Creates a `Point` with an _x_ and _y_ coordinate.
**Example**

```sql
SELECT carto.ST_ASTEXT(carto.ST_MAKEPOINT(-91.8554869, 29.5060349));
-- POINT (-91.8554869 29.5060349)
SELECT carto.ST_ASTEXT(carto.ST_MAKEPOINT(-91.85548, 29.50603));
-- POINT (-91.85548 29.50603)
```
4 changes: 2 additions & 2 deletions clouds/databricks/modules/doc/constructors/ST_POINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Returns a `Point` with the given coordinate values. This is an OGC alias for st_
**Example**

```sql
SELECT carto.ST_ASTEXT(carto.ST_POINT(-91.8554869, 29.5060349));
-- POINT (-91.8554869 29.5060349)
SELECT carto.ST_ASTEXT(carto.ST_POINT(-91.85548, 29.50603));
-- POINT (-91.85548 29.50603)
```
4 changes: 2 additions & 2 deletions clouds/databricks/modules/doc/formatters/ST_ASLATLONTEXT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### ST_ASGEOJSON
### ST_ASLATLONTEXT

{{% bannerNote type="code" %}}
carto.ST_ASGEOJSON(p)
carto.ST_ASLATLONTEXT(p)
{{%/ bannerNote %}}

**Description**
Expand Down
2 changes: 1 addition & 1 deletion clouds/databricks/modules/doc/formatters/ST_ASTEXT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### ST_ASGEOJSON
### ST_ASTEXT

{{% bannerNote type="code" %}}
carto.ST_ASTEXT(geom)
Expand Down
2 changes: 1 addition & 1 deletion clouds/databricks/modules/doc/indexing/ST_GEOMREPROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ WITH t AS (
carto.ST_CRSFROMTEXT('+proj=merc +lat_ts=56.5 +ellps=GRS80') AS crsa,
carto.ST_CRSFROMTEXT('+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs') AS crsb
) SELECT carto.ST_ASTEXT(carto.ST_GEOMREPROJECT(point, crsa, crsb)) FROM t;
-- POINT (0.0000269 0.0000452)
-- POINT (0.00003 0.00005)
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


def test_st_makebbox_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEBBOX(-91.8554869, 29.5060349, -91.8382077, 29.5307334)) AS bbox;'
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEBBOX(-91.85548, 29.50603, -91.83820, 29.53073)) AS bbox;'
result = run_query(query)
assert (
result[0][0]
== 'POLYGON ((-91.8554869 29.5060349, -91.8554869 29.5307334, -91.8382077 29.5307334, -91.8382077 29.5060349, -91.8554869 29.5060349))'
== 'POLYGON ((-91.85548 29.50603, -91.85548 29.53073, -91.8382 29.53073, -91.8382 29.50603, -91.85548 29.50603))'
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


def test_st_makebox2d_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEBOX2D(@@DB_SCHEMA@@.ST_MAKEPOINT(-91.8554869, 29.5060349), @@DB_SCHEMA@@.ST_MAKEPOINT(-91.8382077, 29.5307334))) AS bbox;'
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEBOX2D(@@DB_SCHEMA@@.ST_MAKEPOINT(-91.85548, 29.50603), @@DB_SCHEMA@@.ST_MAKEPOINT(-91.83820, 29.53073))) AS bbox;'
result = run_query(query)
assert (
result[0][0]
== 'POLYGON ((-91.8554869 29.5060349, -91.8554869 29.5307334, -91.8382077 29.5307334, -91.8382077 29.5060349, -91.8554869 29.5060349))'
== 'POLYGON ((-91.85548 29.50603, -91.85548 29.53073, -91.8382 29.53073, -91.8382 29.50603, -91.85548 29.50603))'
)
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


def test_st_makepoint_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEPOINT(-91.8554869, 29.5060349));'
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEPOINT(-91.85548, 29.50603));'
result = run_query(query)
assert result[0][0] == 'POINT (-91.8554869 29.5060349)'
assert result[0][0] == 'POINT (-91.85548 29.50603)'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


def test_st_makepointm_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEPOINTM(-91.8554869, 29.5060349, 5));'
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_MAKEPOINTM(-91.85548, 29.50603, 5));'
result = run_query(query)
assert result[0][0] == 'POINT (-91.8554869 29.5060349)'
assert result[0][0] == 'POINT (-91.85548 29.50603)'
4 changes: 2 additions & 2 deletions clouds/databricks/modules/test/constructors/test_ST_POINT.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


def test_st_point_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_POINT(-91.8554869, 29.5060349));'
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_POINT(-91.85548, 29.50603));'
result = run_query(query)
assert result[0][0] == 'POINT (-91.8554869 29.5060349)'
assert result[0][0] == 'POINT (-91.85548 29.50603)'
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def test_st_geomreproject_success():
@@DB_SCHEMA@@.ST_CRSFROMTEXT('+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs') AS crsb
) SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_GEOMREPROJECT(point, crsa, crsb)) FROM t;"""
result = run_query(query)
assert result[0][0] == 'POINT (0.0000269 0.0000452)'
assert result[0][0] == 'POINT (0.00003 0.00005)'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_st_box2dfromgeohash_success():
query = """WITH t AS (
SELECT @@DB_SCHEMA@@.ST_ASGEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
SELECT @@DB_SCHEMA@@.ST_GEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
)
SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_BOX2DFROMGEOHASH(geohash, 5)) FROM t;"""
result = run_query(query)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_st_geomfromgeohash_success():
query = """WITH t AS (
SELECT @@DB_SCHEMA@@.ST_ASGEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
SELECT @@DB_SCHEMA@@.ST_GEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
)
SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_GEOMFROMGEOHASH(geohash, 8)) FROM t;"""
result = run_query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_st_pointfromgeohash_success():
query = """WITH t AS (
SELECT @@DB_SCHEMA@@.ST_ASGEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
SELECT @@DB_SCHEMA@@.ST_GEOHASH(@@DB_SCHEMA@@.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8) AS geohash
)
SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_POINTFROMGEOHASH(geohash, 5)) FROM t;"""
result = run_query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ def test_st_bufferpoint_success():
query = 'SELECT @@DB_SCHEMA@@.ST_ASTEXT(@@DB_SCHEMA@@.ST_BUFFERPOINT(@@DB_SCHEMA@@.ST_POINT(0, 0), 1));;'
result = run_query(query)
assert result[0][0].startswith(
'POLYGON ((0.000009 0, 0.000009 0.0000006, 0.0000089 0.0000011, 0.0000088 0.0000017,'
'POLYGON ((0.00001 0, 0.00001 0.00001, 0 0.00001, -0.00001 0.00001, -0.00001 0,'
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_st_simplify_success():
result = run_query(query)
assert (
result[0][0]
== 'POLYGON ((0.0000899 0, 0.0000656 0.0000616, 0 0.0000899, -0.0000616 0.0000656, -0.0000899 0, -0.0000656 -0.0000616, 0 -0.0000899, 0.0000616 -0.0000656, 0.0000899 0))'
== 'POLYGON ((0.00009 0, 0.00008 0.00005, 0.00003 0.00009, -0.00005 0.00008, -0.00009 0.00003, -0.00008 -0.00005, -0.00003 -0.00009, 0.00005 -0.00008, 0.00008 -0.00005, 0.00009 0))'
)
assert result[0][1] == 9
assert result[0][2] == 101
assert result[0][1] == 10
assert result[0][2] == 69
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_st_simplifypreservetopology_success():
result = run_query(query)
assert (
result[0][0]
== 'POLYGON ((0.0000899 0, 0 0.0000899, -0.0000899 0, 0 -0.0000899, 0.0000899 0))'
== 'POLYGON ((0.00009 0, 0.00003 0.00009, -0.00009 0.00003, -0.00003 -0.00009, 0.00009 0))'
)
assert result[0][1] == 5
assert result[0][2] == 101
assert result[0][2] == 69