monaco-sql-languages icon indicating copy to clipboard operation
monaco-sql-languages copied to clipboard

How do I get the mapping of an alias in an SQL context?

Open resetsix opened this issue 1 year ago • 9 comments

For example, I have a SQL statement like this: Select u. from user AS u

Currently, the built-in functions of monaco-sql-languages can easily get column data from user., but not through the u. column (u is a custom user alias).

I don't have a good idea of how to implement it.

resetsix avatar Oct 15 '24 06:10 resetsix

const completionService: CompletionService = function ( model, position, completionContext, suggestions, // 语法推荐信息 entities // 当前编辑器文本的语法上下文中出现的表名、字段名等 )

Can alias information be added to the entities attribute?

resetsix avatar Oct 15 '24 09:10 resetsix

For example, I have a SQL statement like this: Select u. from user AS u

Currently, the built-in functions of monaco-sql-languages can easily get column data from user., but not through the u. column (u is a custom user alias).

I don't have a good idea of how to implement it.

你好,感谢你的关注和使用。 关于你提的这个问题是我们后续规划中将要去实现的一个能力。目前我们已经将Table/Catalog/...等的别名信息收集到,但是这只是一个单向的关联关系,后续我们将把别名与原 Table/Catalog/... 之间建立双向关联关系,把别名也作为一个单独实体(或其他方式)收集,有此操作后,它便可拥有与原 Table/Catalog/...一样的字段信息了。 敬请期待我们的新功能~~ 当然,也欢迎你向我们提PR~~

Cythia828 avatar Oct 15 '24 09:10 Cythia828

@Cythia828 Thank you for your reply, this is really good news, and I look forward to the new features.

Can you roughly tell me when the new features will be released? For example, this year.

resetsix avatar Oct 15 '24 10:10 resetsix

@Cythia828 Thank you for your reply, this is really good news, and I look forward to the new features.

Can you roughly tell me when the new features will be released? For example, this year.

你好,感谢你的关注和使用。 关于别名作为实体收集这一功能预计会在未来半年内落地,目前正在向这个结果前进。如果你这边也在做这件事或者有其他好的idea,欢迎随时向我们提PR,也欢迎动手加入我们~~~

Cythia828 avatar Oct 16 '24 01:10 Cythia828

你好,感谢你的关注和使用。 关于别名作为实体收集这一功能预计会在未来半年内落地,目前正在向这个结果前进。如果你这边也在做这件事或者有其他好的idea,欢迎随时向我们提PR,也欢迎动手加入我们~~~

I understand. I hope monaco-sql-languages can add this feature soon, as it is really important for developers.

Also, I noticed that monaco-sql-languages (or dt-sql-parser) only has built-in database keywords, but no function list. I think this feature is also very important for the user's autocomplete experience.

I have temporarily collected a list of database keywords and functions, but I don't know how to pass it to the dt-sql-parser project, because I noticed that it uses g4 syntax. But that's okay, I'm just throwing this out there as an idea.

Here's the repository address I collected: https://github.com/resetsix/db-keywords-and-functions

resetsix avatar Oct 16 '24 02:10 resetsix

你好,感谢你的关注和使用。 关于别名作为实体收集这一功能预计会在未来半年内落地,目前正在向这个结果前进。如果你这边也在做这件事或者有其他好的idea,欢迎随时向我们提PR,也欢迎动手加入我们~~~

I understand. I hope monaco-sql-languages can add this feature soon, as it is really important for developers.

Also, I noticed that monaco-sql-languages (or dt-sql-parser) only has built-in database keywords, but no function list. I think this feature is also very important for the user's autocomplete experience.

I have temporarily collected a list of database keywords and functions, but I don't know how to pass it to the dt-sql-parser project, because I noticed that it uses g4 syntax. But that's okay, I'm just throwing this out there as an idea.

Here's the repository address I collected: https://github.com/resetsix/db-keywords-and-functions

OK,我们已经收到你们的意见了,正在加紧步伐~~~

另外,我们的monaco-sql-languages是有函数关键字的哦,可以查看languages文件夹下对应SQL的builtinFunctions配置,能够发现函数关键字也是有被罗列的哦~~~

Cythia828 avatar Oct 16 '24 02:10 Cythia828

另外,我们的monaco-sql-languages是有函数关键字的哦,可以查看languages文件夹下对应SQL的builtinFunctions配置,能够发现函数关键字也是有被罗列的哦~~~

I have a question: the auto-complete of monaco-sql-languages seems to be incomplete. The keywords in const { keywords, syntax } = suggestions; contain only keywords and not functions. For example, when I type a, only the keywords ADD and ALTER appear in the prompt, but no functions like ABS or ADDTIME. I don't know if this is a problem with monaco-sql-languages or my usage QAQ.

dtstack.github.io/monaco-sql-languages or mortalyoung.github.io/monaco-sql-languages/

图片

It should look like the following

图片

resetsix avatar Oct 16 '24 03:10 resetsix

另外,我们的monaco-sql-languages是有函数关键字的哦,可以查看languages文件夹下对应SQL的builtinFunctions配置,能够发现函数关键字也是有被罗列的哦~~~

I have a question: the auto-complete of monaco-sql-languages seems to be incomplete. The keywords in const { keywords, syntax } = suggestions; contain only keywords and not functions. For example, when I type a, only the keywords ADD and ALTER appear in the prompt, but no functions like ABS or ADDTIME. I don't know if this is a problem with monaco-sql-languages or my usage QAQ.

dtstack.github.io/monaco-sql-languages or mortalyoung.github.io/monaco-sql-languages/

图片 It should look like the following 图片

你好。 关于你提的函数自动补全不全的问题,我们将使用频率较高的关键词/函数名等留在了dt-sql-parser内部,可作为自动补全项提示,如果目前自动补全的函数名无法满足你的需求,你可以调用setupLanguageFeatures去注入你自定义的补全项内容,自定义函数名也可完成自动补全,详细使用可以查看文档。

Cythia828 avatar Oct 17 '24 07:10 Cythia828

你好。 关于你提的函数自动补全不全的问题,我们将使用频率较高的关键词/函数名等留在了dt-sql-parser内部,可作为自动补全项提示,如果目前自动补全的函数名无法满足你的需求,你可以调用setupLanguageFeatures去注入你自定义的补全项内容,自定义函数名也可完成自动补全,详细使用可以查看文档。

感谢。setupLanguageFeatures的用法倒是没什么问题,就是好奇monaco-sql-languages已经内置了builtinFunctions但是在提示的时候只有关键字却没有函数 {{ (>_<) }}。

resetsix avatar Oct 17 '24 08:10 resetsix

@Cythia828

mumiao avatar Nov 19 '24 04:11 mumiao

Dude. Start to answer in English please. Gosh...

BadMachine avatar Mar 27 '25 16:03 BadMachine

It’s been 7 months since the issue created. Any update here?

BadMachine avatar Mar 27 '25 22:03 BadMachine

It’s been 7 months since the issue created. Any update here?

Regarding the feature to collect aliases as entities, we have already prioritized it on our roadmap. However, due to certain unforeseen circumstances, the final implementation has not yet been completed. That said, this feature remains a key focus for 2025 and will definitely be delivered.

Currently, we have already enabled the collection of alias information for existing entities such as tables and catalogs, and you should be able to obtain the required data through alternative approaches.

We sincerely appreciate your interest and apologize for the delayed updates. Stay tuned for further developments!

Cythia828 avatar Mar 28 '25 02:03 Cythia828

It’s been 7 months since the issue created. Any update here?

Table alias is supported, but derived table not supported alias now, we are currently developing it.

See https://github.com/DTStack/dt-sql-parser

Image

JackWang032 avatar Mar 28 '25 02:03 JackWang032