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

support type_id and type_name t-sql functions #1860

Merged

Conversation

vaibhav412
Copy link
Contributor

@vaibhav412 vaibhav412 commented Sep 22, 2023

Description

This commit intends to support TYPE_ID() & TYPE_NAME() T-SQL Functions.

(a) TYPE_ID()
Input: [schema_name].[type_name] OR [type_name]
Output: user_type_id of the datatype
Info: Datatype can be user defined or system default datatype.
-> User Defined datatype:
If new type is created in default schema & same typename is created in another schema, then both will have different type_id.
Example: TYPE_NAME('NewSchema.NewType'), TYPE_ID('NewType') - Both will have different type_id

-> System datatype:
Example: TYPE_ID('int'), TYPE_ID('sys.int'), TYPE_ID('pg_catalog.int') - All will give same type_id.
Reference: Doc

(b) TYPE_NAME()
Input: [type_id]
Output: name of the datatype
Info: It will give the name of the datatype as mapped according to the input type_id.
Example: TYPE_NAME(36)
Reference: Doc

Authored-by: Vaibhav Agarwal [email protected]
Signed-off-by: Vaibhav Agarwal [email protected]

Issues Resolved

[BABEL-803]

Test Scenarios Covered

  • Use case based -
    Added test cases and covered different possible scenarios.

  • Boundary conditions - N/A

  • Arbitrary inputs - N/A

  • Negative test cases - N/A

  • Minor version upgrade tests - N/A

  • Major version upgrade tests - N/A

  • Performance tests - N/A

  • Tooling impact - N/A

  • Client tests - N/A

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
@vaibhav412 vaibhav412 requested a review from Deepesh125 October 3, 2023 09:10
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/sql/sys_functions.sql Outdated Show resolved Hide resolved
Vaibhav Agarwal added 3 commits October 18, 2023 17:16
contrib/babelfishpg_common/src/babelfishpg_common.h Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
test/JDBC/upgrade/master/schedule Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
Vaibhav Agarwal and others added 13 commits October 25, 2023 14:41
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Signed-off-by: Vaibhav Agarwal <[email protected]>
Deepesh125
Deepesh125 previously approved these changes Oct 27, 2023
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_common/src/typecode.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
@Deepesh125 Deepesh125 self-requested a review October 27, 2023 11:29
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/runtime/functions.c Outdated Show resolved Hide resolved
Signed-off-by: Vaibhav Agarwal <[email protected]>
@vaibhav412 vaibhav412 requested a review from Deepesh125 November 7, 2023 07:26
@Deepesh125 Deepesh125 merged commit a26d448 into babelfish-for-postgresql:BABEL_3_X_DEV Nov 7, 2023
28 checks passed
@Deepesh125 Deepesh125 deleted the JIRA-BABEL-803 branch November 7, 2023 08:21
staticlibs pushed a commit to wiltondb/babelfish_extensions that referenced this pull request Oct 20, 2024
…ql#1860)

This commit intends to support two T-SQL Functions, TYPE_ID() and TYPE_NAME().

1. TYPE_ID()
Input: [schema_name].[type_name] OR [type_name]
Output: user_type_id of the datatype
Info: Datatype can be user defined or system default datatype.
-> For User Defined datatype: If new type is created in default schema & same typename is created in another schema,
then both will have different type_id depending on whether schema is specified.
Example: TYPE_NAME('NewSchema.NewType'), TYPE_ID('NewType') - Both will have different type_id because later one will try to search in default user schema or guest schema.
-> System datatype:
Example: TYPE_ID('int'), TYPE_ID('sys.int'), TYPE_ID('pg_catalog.int') - All will give same type_id unless user defined type with same name is created in other schema and input is schema qualified.

(b) TYPE_NAME()
Input: [type_id]
Output: name of the datatype
Info: It will give the name of the datatype as mapped according to the input type_id.
Example: TYPE_NAME(36)

Task: BABEL-803
Signed-off-by: Vaibhav Agarwal <[email protected]>
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