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(flinksql): collect comment, type attribute for entity #319

Merged
merged 11 commits into from
Jul 5, 2024

Conversation

Cythia828
Copy link
Collaborator

@Cythia828 Cythia828 commented Jun 20, 2024

Feature

  1. 收集字段时,收集字段的类型和字段注释
  2. 收集新建实体名时,收集实体的注释信息,如果有的话

Fix

  1. 修复 [Bug]: ctxToWord is a bad function  #305

Description

  1. 关于用带_取属性名,antlr4ng目前解析出来属性名都是带_,是公有的。甚至以type命名前后都有下划线,应该是以防重名,无关私有公有
  2. 关于findAttributeChildren方法里的child类型,因为antlr4ng 的ParserRuleContext里,children并未重申类型,导致children类型为ParseTree[],需要和三方提PR修改
  3. 关于table alias,需要作为实体去收集,当前PR不放相关内容
  4. 调整实体类型,将实体分为常规实体、方法实体、字段实体。值得一提的是,实体均带有isAlias属性和aliasreferencecomment几个可选属性,alias为别名,reference为被引用的实体。

@Cythia828 Cythia828 changed the base branch from main to next July 1, 2024 01:47
src/grammar/flink/FlinkSqlParser.g4 Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
this.pushEntity(ctx, EntityContextType.DATABASE_CREATE, {
needCollectAttr: true,
attrList: [attrName.comment],
endContext: 'CreateDatabaseContext',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以用 CreateDatabaseContext.constructor.name 代替吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不可以哦,在这里CreateDatabaseContext.constructor.name 是Function

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateDatabaseContext.name

src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
@Cythia828
Copy link
Collaborator Author

@liuxy0551 @HaydenOrz 关于你们的comment,已经提交了新的commit,可以再次review一下

src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
return 'line' in value;
}

export function isColumnEntityContext(value: EntityContext): value is ColumnEntityContext {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
return 'params' in value && 'returns' in value && 'relatedEntities' in value;
}

export function isWordRange(value: any): value is WordRange {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,且参数类型应该是 TextSlice | WordRange

src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
src/parser/common/entityCollector.ts Outdated Show resolved Hide resolved
this.pushEntity(ctx, EntityContextType.DATABASE_CREATE, {
needCollectAttr: true,
attrList: [attrName.comment],
endContext: 'CreateDatabaseContext',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateDatabaseContext.name

@Cythia828
Copy link
Collaborator Author

@HaydenOrz 优化的commit已提交,可再次review

@HaydenOrz HaydenOrz merged commit a94e7fc into DTStack:next Jul 5, 2024
5 checks passed
@Cythia828 Cythia828 deleted the feat/collect_attribute branch July 5, 2024 08:03
Cythia828 added a commit to Cythia828/dt-sql-parser that referenced this pull request Aug 2, 2024
* feat(flinksql): collect comment, type attribute for entity

* feat(flinksql): delete console log

* fix(DTStack#305): delete function ctxToWord,using ctxToText instead of ctxToWord

* feat: update attribute's type

* feat(flinksql): update flinksql's entitycollect unit test

* feat: optimize interface and update unit test

* feat: update collect attr detail

* feat: optimize interface and some function's arguments

* feat: add comment and update params' name

* feat: collect alias in select statement

* feat: update collect attribute function and update unit test

---------

Co-authored-by: zhaoge <>
HaydenOrz pushed a commit that referenced this pull request Aug 2, 2024
* feat(flinksql): collect comment, type attribute for entity

* feat(flinksql): delete console log

* fix(#305): delete function ctxToWord,using ctxToText instead of ctxToWord

* feat: update attribute's type

* feat(flinksql): update flinksql's entitycollect unit test

* feat: optimize interface and update unit test

* feat: update collect attr detail

* feat: optimize interface and some function's arguments

* feat: add comment and update params' name

* feat: collect alias in select statement

* feat: update collect attribute function and update unit test

---------

Co-authored-by: zhaoge <>
Cythia828 added a commit to Cythia828/dt-sql-parser that referenced this pull request Aug 2, 2024
* feat(flinksql): collect comment, type attribute for entity

* feat(flinksql): delete console log

* fix(DTStack#305): delete function ctxToWord,using ctxToText instead of ctxToWord

* feat: update attribute's type

* feat(flinksql): update flinksql's entitycollect unit test

* feat: optimize interface and update unit test

* feat: update collect attr detail

* feat: optimize interface and some function's arguments

* feat: add comment and update params' name

* feat: collect alias in select statement

* feat: update collect attribute function and update unit test

---------

Co-authored-by: zhaoge <>
HaydenOrz pushed a commit to HaydenOrz/dt-sql-parser that referenced this pull request Aug 27, 2024
* feat(flinksql): collect comment, type attribute for entity

* feat(flinksql): delete console log

* fix(DTStack#305): delete function ctxToWord,using ctxToText instead of ctxToWord

* feat: update attribute's type

* feat(flinksql): update flinksql's entitycollect unit test

* feat: optimize interface and update unit test

* feat: update collect attr detail

* feat: optimize interface and some function's arguments

* feat: add comment and update params' name

* feat: collect alias in select statement

* feat: update collect attribute function and update unit test

---------

Co-authored-by: zhaoge <>
HaydenOrz pushed a commit that referenced this pull request Oct 17, 2024
* feat(flinksql): collect comment, type attribute for entity

* feat(flinksql): delete console log

* fix(#305): delete function ctxToWord,using ctxToText instead of ctxToWord

* feat: update attribute's type

* feat(flinksql): update flinksql's entitycollect unit test

* feat: optimize interface and update unit test

* feat: update collect attr detail

* feat: optimize interface and some function's arguments

* feat: add comment and update params' name

* feat: collect alias in select statement

* feat: update collect attribute function and update unit test

---------

Co-authored-by: zhaoge <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants