-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Kusto functions support #2572
Kusto functions support #2572
Conversation
Does Kusto have functions and stored procedures?? |
If not, then we should just add a check for Kusto in the scaffolder, and not attempt to scaffold procedures and functions if we are running against Kusto |
And mayb revert Kusto related changes in these classes? |
src/Core/RevEng.Core.60/Routines/SqlServerRoutineModelFactory.cs
Outdated
Show resolved
Hide resolved
no, they have function table, kusto views is function without params, also they have function table with params, so i need the function table support |
Wonder if we can discover them - at any reate, we should just refarin from trying to scaffold stored procedure, so changes to SqlServerRoutineModelFactory.cs are not needed, we need to add a check in ReverseEngineerRunner instead |
src/Core/RevEng.Core.60/Routines/Functions/SqlServerFunctionModelFactory.cs
Outdated
Show resolved
Hide resolved
Have you managed to smoke test this with Kusto AND a SQL database with functions? |
managed to run e2e on kusto, and run the specific query on sql server online emulator (doesnt have real sql server) |
@barnuri You can spin up AdventureWorks on an Azure SQL database, it has some SQL functions |
@barnuri I will try this PR branch against Adventureworks (or another database with Functions and stored procedures) |
Just tested with Adventureworks, and getting errors - I am reluctant to accept this PR, the queries should be left alone for non_Kusto usage, suggest that a variation for Kusto is used instead. |
|
Can you find accountnumber ? |
Regardsless, there are too many changes to these two queries, that have worked well and contain a lot of knowledge |
These two queries return wildliy dfferent results against AdventureWorks: SELECT
'Parameter' = p.name,
'Type' = COALESCE(ts.name, tu.name),
'Length' = CAST(p.max_length AS INT),
'Precision' = CASE
WHEN ts.name = 'uniqueidentifier' THEN p.precision
WHEN ts.name IN ('decimal', 'numeric') THEN p.precision
WHEN ts.name IN ('varchar', 'nvarchar') THEN p.max_length
ELSE NULL
END,
'Scale' = CAST(p.scale AS INT),
'Order' = CAST(p.parameter_id AS INT),
p.is_output AS output,
'TypeName' = QUOTENAME(s.name) + '.' + QUOTENAME(tu.name),
'TypeSchema' = tu.schema_id,
'TypeId' = p.user_type_id,
'RoutineName' = o.name,
'RoutineSchema' = s.name
from sys.parameters p
inner join sys.objects AS o on o.object_id = p.object_id
inner JOIN sys.schemas AS s ON o.schema_id = s.schema_id
left JOIN sys.types AS tu ON p.user_type_id = tu.user_type_id
left JOIN sys.types AS ts ON p.system_type_id = ts.system_type_id
ORDER BY p.object_id, p.parameter_id; SELECT
'Parameter' = p.name,
'Type' = COALESCE(type_name(p.system_type_id), type_name(p.user_type_id)),
'Length' = CAST(p.max_length AS INT),
'Precision' = CAST(case when type_name(p.system_type_id) = 'uniqueidentifier'
then p.precision
else OdbcPrec(p.system_type_id, p.max_length, p.precision) end AS INT),
'Scale' = CAST(OdbcScale(p.system_type_id, p.scale) AS INT),
'Order' = CAST(parameter_id AS INT),
p.is_output AS output,
'TypeName' = QUOTENAME(SCHEMA_NAME(t.schema_id)) + '.' + QUOTENAME(TYPE_NAME(p.user_type_id)),
'TypeSchema' = t.schema_id,
'TypeId' = p.user_type_id,
'RoutineName' = OBJECT_NAME(p.object_id),
'RoutineSchema' = OBJECT_SCHEMA_NAME(p.object_id)
from sys.parameters p
LEFT JOIN sys.table_types t ON t.user_type_id = p.user_type_id
ORDER BY p.object_id, p.parameter_id;
|
do you have suggestions ? maybe we can do if kusto use the new query ? what do you think ? |
fixed the first sql
|
@ErikEJ the first query return the same |
Leaving this until the feedback on the EF Core pr has been addressed |
how it's connected ? the only left comment there is on something that i didnt changed here |
update all the places from the prev PR too like i fixed in EF Core pr, found a solution with less changes the efcore team probably will like validate the change with efcpt.8 with kusto (smoking test) |
Cool, will have a look soon |
Have you rebased on latest master? |
yeah, i sync fork master and then pull fork master to this branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of changes needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets revert any changes to this file, the EF Core 6 tools does not support Kusto anyway, and I will remove EF 6 support soon anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, reverted
src/Core/RevEng.Core.80/PatchedSqlServerDatabaseModelFactory.cs
Outdated
Show resolved
Hide resolved
Thanks @barnuri for a great contribution |
@barnuri any plans to share this via a blog post or similar?? |
never done that before, if you have an example of something or write by your blog its great too also can you update here ? i think they waiting for your response |
in GetParameters the sql methods type_name, OdbcPrec, OdbcScale, OBJECT_NAME, OBJECT_SCHEMA_NAME not supported
in GetResultElementLists the sql methods type_name, OBJECT_ID is not supported
replace all by join with relevant tables