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

feat: internal service to translate predicates to SQL WHERE #356

Open
MortenHofft opened this issue Oct 31, 2024 · 1 comment
Open

feat: internal service to translate predicates to SQL WHERE #356

MortenHofft opened this issue Oct 31, 2024 · 1 comment
Assignees

Comments

@MortenHofft
Copy link
Member

For the b3 project we need to create an easy way to generate sql cubes via the UI.

The select and grouping I suppose I would do in a custom service, but it would be nice to reuse the existing predicate => sql code. As far as i understand we already have this code.

In short I would like a service that takes a predicate and returns the WHERE part of an SQL query

@MortenHofft
Copy link
Member Author

MortenHofft commented Feb 4, 2025

More complex predicates than basic one fails. I haven't tried to figure out exactly when it fails. So it is a somewhat vague issue. But here is an example (I believe it is a valid predicate)

{
  "type": "and",
  "predicates": [
    {
      "type": "and",
      "predicates": [
        {
          "type": "in",
          "key": "COUNTRY",
          "values": [
            "US",
            "UM",
            "AS",
            "FM",
            "GU",
            "MH",
            "MP",
            "PR",
            "PW",
            "VI"
          ]
        },
        {
          "type": "not",
          "predicate": {
            "type": "equals",
            "key": "ISSUE",
            "value": "COUNTRY_COORDINATE_MISMATCH"
          }
        }
      ]
    },
    {
      "type": "and",
      "predicates": [
        {
          "type": "in",
          "key": "OCCURRENCE_STATUS",
          "values": [
            "PRESENT"
          ]
        },
        {
          "type": "not",
          "predicate": {
            "type": "in",
            "key": "ISSUE",
            "values": [
              "ZERO_COORDINATE"
            ]
          }
        },
        {
          "type": "not",
          "predicate": {
            "type": "isNotNull",
            "parameter": "GADM_GID"
          }
        }
      ]
    }
  ]
}

@MortenHofft MortenHofft reopened this Feb 4, 2025
MortenHofft added a commit to gbif/gbif-web that referenced this issue Feb 4, 2025
MattBlissett added a commit to gbif/gbif-predicates that referenced this issue Feb 5, 2025
MattBlissett added a commit to gbif/gbif-predicates that referenced this issue Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants