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

查询语句校验边或点的字段是否存在 #5108

Open
GitLLTT opened this issue Dec 23, 2022 · 1 comment
Open

查询语句校验边或点的字段是否存在 #5108

GitLLTT opened this issue Dec 23, 2022 · 1 comment
Labels
type/feature req Type: feature request

Comments

@GitLLTT
Copy link

GitLLTT commented Dec 23, 2022

Is your feature request related to a problem? Please describe.

问题:目前查询语句没有校验字段是否存在,字段名是否正确的功能
Describe the solution you'd like

建议:希望增加校验字段名是否存在的功能
Describe alternatives you've considered

Additional context

@xtcyclist
Copy link
Contributor

xtcyclist commented Jan 12, 2023

你好,这个问题在当前版本中还是比较复杂的,因为当前版本同时支持 nGQL 和 openCypher,同时支持强 schema 和弱 schema 两种情形,有的字段缺失会报错,有的并不会,体现为 NULL 或者 UNKOWN_PROP 等 NULL 值。

请问具体到你的需求,你是希望只要有字段不存在的记录存在,查询就直接报错吗?

下面简单介绍一下现状:

对于点来说:

  1. 如果一个 tag 不存在,match (v:test) where id(v) == "Tim Duncan" return v;,目前会报错:[ERROR (-1009)]: SemanticError: `test': Unknown tag
  2. 如果一个 tag 存在,但是相应的点上没有这个 tag,当前版本不会报错,比如 match (v:team) where id(v) == "Tim Duncan" return v;,返回是空的 result set。
  3. 如果查询一个不存在的属性,比如match (v) where id(v) == "Tim Duncan" return v.team.name; ,不会报错,但是结果可能有不同情形,有的 query 下是__NULL__,有时是UNKNOWN_PROP,这是因为当前版本同时支持 nGQL 和 openCyper 造成的。

对于边来说:

如下语句为例,如果有相应属性,能返回;没有的话,返回__NULL__

(root@nebula) [nba]> match (v:player)-[e]-() where id(v) == "Tim Duncan" return e.likeness, e;
+------------+-------------------------------------------------------------------------------------+
| e.likeness | e                                                                                   |
+------------+-------------------------------------------------------------------------------------+
| __NULL__   | [:teammate "Manu Ginobili"->"Tim Duncan" @0 {end_year: 2016, start_year: 2002}]     |
| __NULL__   | [:teammate "Tony Parker"->"Tim Duncan" @0 {end_year: 2016, start_year: 2001}]       |
| __NULL__   | [:teammate "Tim Duncan"->"Danny Green" @0 {end_year: 2016, start_year: 2010}]       |
| __NULL__   | [:teammate "Tim Duncan"->"LaMarcus Aldridge" @0 {end_year: 2016, start_year: 2015}] |
| __NULL__   | [:teammate "Tim Duncan"->"Manu Ginobili" @0 {end_year: 2016, start_year: 2002}]     |
| __NULL__   | [:teammate "Tim Duncan"->"Tony Parker" @0 {end_year: 2016, start_year: 2001}]       |
| __NULL__   | [:serve "Tim Duncan"->"Spurs" @0 {end_year: 2016, start_year: 1997}]                |
| 80         | [:like "Aron Baynes"->"Tim Duncan" @0 {likeness: 80}]                               |
| 80         | [:like "Boris Diaw"->"Tim Duncan" @0 {likeness: 80}]                                |
| 70         | [:like "Danny Green"->"Tim Duncan" @0 {likeness: 70}]                               |
| 99         | [:like "Dejounte Murray"->"Tim Duncan" @0 {likeness: 99}]                           |
| 75         | [:like "LaMarcus Aldridge"->"Tim Duncan" @0 {likeness: 75}]                         |
| 90         | [:like "Manu Ginobili"->"Tim Duncan" @0 {likeness: 90}]                             |
| 55         | [:like "Marco Belinelli"->"Tim Duncan" @0 {likeness: 55}]                           |
| 80         | [:like "Shaquille O'Neal"->"Tim Duncan" @0 {likeness: 80}]                          |
| 80         | [:like "Tiago Splitter"->"Tim Duncan" @0 {likeness: 80}]                            |
| 95         | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}]                               |
| 95         | [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}]                             |
| 95         | [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}]                               |
+------------+-------------------------------------------------------------------------------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature req Type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants