tarantool / tarantool/tarantool

sql: introduce <CREATE TYPE> statement

Open
#3,837 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature sql sql static types
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

ANSI SQL allows to create user-defined types. See 11.51 <user-defined type definition>.
Nevertheless, Tarantool doesn't support this feature yet, but we can use this statement at least for creating type aliases:
CREATE TYPE AGE_TYPE AS INTEGER;

This feature may be useful taking into consideration user-defined CAST operator: if user wants to use custom casting rules, but don't want to break it for all usages of given type, one can create alias for that type and define CAST operator.

For instance, user is willing to ban conversion from FLOAT to INT:

CREATE TYPE NEW_INT AS INTEGER;
CREATE CAST (float AS NEW_INT) WITH FUNCTION new_int_cast(NEW_INT) AS ASSIGNMENT;

In this example new_int_cast() function would throw error indicating the fact that conversion is not allowed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the referenced ANSI SQL 11.51 user-defined type definition and the CREATE TYPE and CREATE CAST examples in this issue. No implementation files or tests are named; done means supporting type aliases such as AGE_TYPE AS INTEGER and allowing casts to the alias without changing the original type's behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.