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

[FEATURE]: Unlocking Endless Possibilities: Exposing an AST Endpoint in Dgraph #8888

Open
MichelDiz opened this issue Jun 26, 2023 · 0 comments
Labels
dgraph Issue or PR created by an internal Dgraph contributor. kind/feature Something completely new we should consider.

Comments

@MichelDiz
Copy link
Contributor

MichelDiz commented Jun 26, 2023

Use case

Related to #8887

Dgraph, known for its performance and scalability, can take a revolutionary step forward by exposing an endpoint that accepts pure Abstract Syntax Trees (AST). This goes beyond the conventional Dgraph Query Language (DQL), opening the door to compatibility with an assortment of query languages such as Cypher, SPARQL, and potentially even SQL. Here’s why this is a game-changing proposal:

Unparalleled Flexibility: By accepting pure ASTs, Dgraph will allow users to write queries in languages they are already familiar with. This opens up an unparalleled level of flexibility, where developers can choose the best-suited query language for their specific use cases and datasets.

Community-driven Extensions: Exposing an AST endpoint will likely galvanize the community to create parsers for various query languages. As an open canvas, this can lead to rapid innovations and extensions, with enthusiasts contributing parsers for languages such as Cypher, and potentially, with concerted efforts, even SQL.

Enhanced Data Integration: Many existing systems and datasets employ specific query languages. By supporting a variety of query languages through the AST endpoint, Dgraph can integrate more seamlessly with existing systems, thus enhancing data interoperability and streamlining data exchange.

Customization and Optimization: Accepting ASTs allows users to perform highly customized and optimized queries tailored to their specific needs. This goes beyond the constraints of any single query language, empowering users to achieve performance gains through optimization at the AST level.

Education and Skill Transferability: For individuals and organizations already well-versed in SQL, Cypher, or other query languages, the ability to use these languages with Dgraph means that they can leverage their existing knowledge and expertise. This eases the learning curve and accelerates the onboarding process.

Competitive Edge: Offering an AST endpoint that accepts multiple query languages would provide Dgraph with a significant competitive advantage over other graph databases. This unique feature can be a key differentiator, attracting both individual developers and enterprise clients.

Links to Discuss, RFC or previous Issues and PRs

No response

Links to examples and research

No response

Current state

No response

Solution proposal

No response

Additional Information

Here is an example of DQL AST

{
  "Query": [
    {
      "UID": [
        200
      ],
      "Attr": "",
      "Langs": null,
      "Alias": "q",
      "IsCount": false,
      "IsInternal": false,
      "IsGroupby": false,
      "Var": "",
      "NeedsVar": null,
      "Func": {
        "Attr": "",
        "Lang": "",
        "Name": "uid",
        "Args": null,
        "UID": null,
        "NeedsVar": null,
        "IsCount": false,
        "IsValueVar": false,
        "IsLenVar": false
      },
      "Expand": "",
      "Args": {},
      "Order": null,
      "Children": [
        {
          "UID": null,
          "Attr": "math",
          "Langs": null,
          "Alias": "test",
          "IsCount": false,
          "IsInternal": true,
          "IsGroupby": false,
          "Var": "G",
          "NeedsVar": null,
          "Func": null,
          "Expand": "",
          "Args": {},
          "Order": null,
          "Children": null,
          "Filter": null,
          "MathExp": {
            "Fn": "+",
            "Var": "",
            "Const": "",
            "Val": null,
            "Child": [
              {
                "Fn": "",
                "Var": "",
                "Const": 1,
                "Val": null,
                "Child": null
              },
              {
                "Fn": "",
                "Var": "",
                "Const": 2,
                "Val": null,
                "Child": null
              }
            ]
          },
          "Normalize": false,
          "Recurse": false,
          "RecurseArgs": {
            "Depth": 0,
            "AllowLoop": false
          },
          "ShortestPathArgs": {
            "From": null,
            "To": null
          },
          "Cascade": null,
          "IgnoreReflex": false,
          "Facets": null,
          "FacetsFilter": null,
          "GroupbyAttrs": null,
          "FacetVar": null,
          "FacetsOrder": null,
          "AllowedPreds": null,
          "IsEmpty": false
        },
        {
          "UID": null,
          "Attr": "name",
          "Langs": null,
          "Alias": "",
          "IsCount": false,
          "IsInternal": false,
          "IsGroupby": false,
          "Var": "",
          "NeedsVar": null,
          "Func": null,
          "Expand": "",
          "Args": {},
          "Order": null,
          "Children": null,
          "Filter": null,
          "MathExp": null,
          "Normalize": false,
          "Recurse": false,
          "RecurseArgs": {
            "Depth": 0,
            "AllowLoop": false
          },
          "ShortestPathArgs": {
            "From": null,
            "To": null
          },
          "Cascade": null,
          "IgnoreReflex": false,
          "Facets": null,
          "FacetsFilter": null,
          "GroupbyAttrs": null,
          "FacetVar": null,
          "FacetsOrder": null,
          "AllowedPreds": null,
          "IsEmpty": false
        },
        {
          "UID": null,
          "Attr": "posts",
          "Langs": null,
          "Alias": "",
          "IsCount": false,
          "IsInternal": false,
          "IsGroupby": false,
          "Var": "",
          "NeedsVar": null,
          "Func": null,
          "Expand": "",
          "Args": {},
          "Order": [
            {
              "attr": "date",
              "desc": true
            }
          ],
          "Children": [
            {
              "UID": null,
              "Attr": "title",
              "Langs": null,
              "Alias": "",
              "IsCount": false,
              "IsInternal": false,
              "IsGroupby": false,
              "Var": "",
              "NeedsVar": null,
              "Func": null,
              "Expand": "",
              "Args": {},
              "Order": null,
              "Children": null,
              "Filter": null,
              "MathExp": null,
              "Normalize": false,
              "Recurse": false,
              "RecurseArgs": {
                "Depth": 0,
                "AllowLoop": false
              },
              "ShortestPathArgs": {
                "From": null,
                "To": null
              },
              "Cascade": null,
              "IgnoreReflex": false,
              "Facets": null,
              "FacetsFilter": null,
              "GroupbyAttrs": null,
              "FacetVar": null,
              "FacetsOrder": null,
              "AllowedPreds": null,
              "IsEmpty": false
            }
          ],
          "Filter": {
            "Op": "",
            "Child": null,
            "Func": {
              "Attr": "date",
              "Lang": "",
              "Name": "ge",
              "Args": [
                {
                  "Value": "2015-08-01T00:00:00Z",
                  "IsValueVar": false,
                  "IsGraphQLVar": false
                }
              ],
              "UID": null,
              "NeedsVar": null,
              "IsCount": false,
              "IsValueVar": false,
              "IsLenVar": false
            }
          },
          "MathExp": null,
          "Normalize": false,
          "Recurse": false,
          "RecurseArgs": {
            "Depth": 0,
            "AllowLoop": false
          },
          "ShortestPathArgs": {
            "From": null,
            "To": null
          },
          "Cascade": null,
          "IgnoreReflex": false,
          "Facets": null,
          "FacetsFilter": null,
          "GroupbyAttrs": null,
          "FacetVar": null,
          "FacetsOrder": null,
          "AllowedPreds": null,
          "IsEmpty": false
        }
      ],
      "Filter": null,
      "MathExp": null,
      "Normalize": true,
      "Recurse": false,
      "RecurseArgs": {
        "Depth": 0,
        "AllowLoop": false
      },
      "ShortestPathArgs": {
        "From": null,
        "To": null
      },
      "Cascade": null,
      "IgnoreReflex": false,
      "Facets": null,
      "FacetsFilter": null,
      "GroupbyAttrs": null,
      "FacetVar": null,
      "FacetsOrder": null,
      "AllowedPreds": null,
      "IsEmpty": false
    },
    {
      "UID": null,
      "Attr": "",
      "Langs": null,
      "Alias": "me",
      "IsCount": false,
      "IsInternal": false,
      "IsGroupby": false,
      "Var": "",
      "NeedsVar": null,
      "Func": null,
      "Expand": "",
      "Args": {},
      "Order": null,
      "Children": [
        {
          "UID": null,
          "Attr": "val",
          "Langs": null,
          "Alias": "",
          "IsCount": false,
          "IsInternal": true,
          "IsGroupby": false,
          "Var": "",
          "NeedsVar": [
            {
              "Name": "G",
              "Typ": 2
            }
          ],
          "Func": {
            "Attr": "",
            "Lang": "",
            "Name": "max",
            "Args": null,
            "UID": null,
            "NeedsVar": [
              {
                "Name": "G",
                "Typ": 2
              }
            ],
            "IsCount": false,
            "IsValueVar": false,
            "IsLenVar": false
          },
          "Expand": "",
          "Args": {},
          "Order": null,
          "Children": null,
          "Filter": null,
          "MathExp": null,
          "Normalize": false,
          "Recurse": false,
          "RecurseArgs": {
            "Depth": 0,
            "AllowLoop": false
          },
          "ShortestPathArgs": {
            "From": null,
            "To": null
          },
          "Cascade": null,
          "IgnoreReflex": false,
          "Facets": null,
          "FacetsFilter": null,
          "GroupbyAttrs": null,
          "FacetVar": null,
          "FacetsOrder": null,
          "AllowedPreds": null,
          "IsEmpty": false
        }
      ],
      "Filter": null,
      "MathExp": null,
      "Normalize": false,
      "Recurse": false,
      "RecurseArgs": {
        "Depth": 0,
        "AllowLoop": false
      },
      "ShortestPathArgs": {
        "From": null,
        "To": null
      },
      "Cascade": null,
      "IgnoreReflex": false,
      "Facets": null,
      "FacetsFilter": null,
      "GroupbyAttrs": null,
      "FacetVar": null,
      "FacetsOrder": null,
      "AllowedPreds": null,
      "IsEmpty": true
    }
  ],
  "QueryVars": [
    {
      "Defines": [
        "G"
      ],
      "Needs": null
    },
    {
      "Defines": null,
      "Needs": [
        "G"
      ]
    }
  ],
  "Schema": null
}
@MichelDiz MichelDiz added kind/feature Something completely new we should consider. dgraph Issue or PR created by an internal Dgraph contributor. labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dgraph Issue or PR created by an internal Dgraph contributor. kind/feature Something completely new we should consider.
Development

No branches or pull requests

1 participant