这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@lexi-lambda
Copy link
Contributor

Description

This adds a new _cast operator to boolean comparison expressions for fields of type geometry and geography. This allows queries to take advantage of both the more efficient and featureful operations on geometry and the more accurate distance calculations of geography, regardless of how the data is actually stored. The following syntax is used for queries that use casts:

{
  geom_table(where: {
    geom_col: {
      _cast: {
        geography: {
          _st_d_within: {
            distance: 1000000
            from: { type: "Point", coordinates: [1, 50] }
          }
        }
      }
    }
  }){
    name
  }
}

Affected components

  • Server
  • Docs

Related Issues

#1983

Solution and Design

This particular approach hardwires casts between geometry and geography types into the schema generation, but that isn’t strictly necessary, and the actual SQL generation supports arbitrary casts.

I explored a little what it would involve to use the pg_casts table to generate casts, and it isn’t that hard, but I’m not sure if it’s useful for anything other than this particular use case, so this just bakes those casts in for now.

Steps to test and verify

Limitations, known bugs & workarounds

@lexi-lambda lexi-lambda added c/docs Related to docs c/server Related to server s/wip Status: This issue is a work in progress k/enhancement New feature or improve an existing feature labels Jul 9, 2019
@netlify
Copy link

netlify bot commented Jul 9, 2019

Deploy preview for hasura-docs ready!

Built with commit a7e6d5c

https://deploy-preview-2495--hasura-docs.netlify.com

@hasura-bot
Copy link
Contributor

Review app for commit 00b846d deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-00b846d6

@hasura-bot
Copy link
Contributor

Review app for commit 534a40a deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-534a40a7

@lexi-lambda lexi-lambda marked this pull request as ready for review July 9, 2019 19:22
@lexi-lambda lexi-lambda removed the s/wip Status: This issue is a work in progress label Jul 9, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 1f48fba deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-1f48fba4

@hasura-bot
Copy link
Contributor

Review app for commit ea348a0 deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-ea348a04

@hasura-bot
Copy link
Contributor

Review app for commit 0c90e2b deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-0c90e2bf

@hasura-bot
Copy link
Contributor

Review app for commit f65db63 deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-f65db63d

0x777
0x777 previously approved these changes Jul 12, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 71f46df deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-71f46dfd

@hasura-bot
Copy link
Contributor

Review app for commit a7e6d5c deployed to Heroku: https://hge-ci-pull-2495.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2495-a7e6d5c0

@0x777 0x777 merged commit 8f9a41f into hasura:master Jul 15, 2019
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-2495.herokuapp.com is deleted

@hasura-bot
Copy link
Contributor

Beep boop! 🤖

GIF

Awesome work @lexi-lambda! All of us at Hasura ❤️ what you did.

Thanks again 🤗

@lexi-lambda lexi-lambda deleted the geometry-casts branch July 22, 2019 12:50
polRk pushed a commit to polRk/graphql-engine that referenced this pull request Feb 12, 2020
…e` expressions (close hasura#1983) (hasura#2495)

* server: Bump dependencies to allow Haddock to run successfully

* Support casting between PostGIS geometry and geography types in filters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/docs Related to docs c/server Related to server k/enhancement New feature or improve an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants