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

Fix Snowflake spatial index detection #845

Merged
merged 2 commits into from
Mar 5, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## Not released
- Fix Snowflake spatial index detection [#845](https://github.com/CartoDB/carto-react/pull/845)
- Fix TimeSeriesWidgetUI check undefined echart.getInstance().getDom() [#842](https://github.com/CartoDB/carto-react/pull/842)

## 2.3
Expand Down
6 changes: 6 additions & 0 deletions packages/react-core/__tests__/utils/columns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ describe('getColumnNameFromGeoColumn', () => {
describe('getSpatialIndexFromGeoColumn', () => {
it('detect simple spatial index', () => {
expect(getSpatialIndexFromGeoColumn('quadbin')).toStrictEqual('quadbin');
expect(getSpatialIndexFromGeoColumn('QUADBIN')).toStrictEqual('quadbin');
expect(getSpatialIndexFromGeoColumn('h3')).toStrictEqual('h3');
expect(getSpatialIndexFromGeoColumn('H3')).toStrictEqual('h3');
expect(getSpatialIndexFromGeoColumn('s2')).toStrictEqual('s2');
expect(getSpatialIndexFromGeoColumn('S2')).toStrictEqual('s2');
});

it('detect prefix spatial index', () => {
expect(getSpatialIndexFromGeoColumn('quadbin:abc')).toStrictEqual('quadbin');
expect(getSpatialIndexFromGeoColumn('QUADBIN:ABC')).toStrictEqual('quadbin');
expect(getSpatialIndexFromGeoColumn('h3:abc')).toStrictEqual('h3');
expect(getSpatialIndexFromGeoColumn('H3:abc')).toStrictEqual('h3');
expect(getSpatialIndexFromGeoColumn('s2:abc')).toStrictEqual('s2');
expect(getSpatialIndexFromGeoColumn('S2:abc')).toStrictEqual('s2');
});

it('handle unsupported spatial index', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-core/src/utils/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function getColumnNameFromGeoColumn(geoColumn) {
export function getSpatialIndexFromGeoColumn(geoColumn) {
const parts = geoColumn.split(':');
return (parts.length === 1 || parts.length === 2) &&
Object.values(SpatialIndex).includes(parts[0])
? parts[0]
Object.values(SpatialIndex).includes(parts[0].toLowerCase())
? parts[0].toLowerCase()
: null;
}
Loading