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

Create a release #3

Closed
raganhan opened this issue May 17, 2019 · 1 comment
Closed

Create a release #3

raganhan opened this issue May 17, 2019 · 1 comment

Comments

@raganhan
Copy link
Contributor

The Getting Started instructions say:

The easiest way to get started with {productName} is to clone this repository locally, build, then run the REPL.

In order to lower the bar for adoption, provide a release in the Releases tab. This will allow users to get started with it much easily.

@arun-gupta
Copy link

This is a critical piece for adoption.

am357 added a commit that referenced this issue Jul 26, 2024
```SQL
CREATE TABLE PETS (
    id INT4,
    breed STRING,
    tag INT2
)
```

Tests:
```SQL
-- #1 should succeed
CAST(true AS INT2) --

-- #2  should fail
CAST((s : STRING) AS LIST)

-- #3 should succeed
CAST((i : INT2) AS INT4)

-- #4 should succeed
CAST((i : INT4) AS INT2)
```

#### Background context
As part of a specification work, we want to make the behavior for the #4 more visible:

 From SQL-99 Section 6.22: <cast specification>:

```
 If SD (source data type) is exact numeric or approximate numeric, then
 Case:
   i) If there is a representation of SV (source value) in the data type TD (target data type) that does not lose any leading si-gnificant digits after rounding or truncating if necessary, then TV is that representation.
 The choice of whether to round or truncate is implementation-defined.
 ii) Otherwise, an exception condition is raised: data exception — numeric value out of
 range.
 ```

We can see this evaluation behavior in PostgresSQL v15:
Ref.: https://www.db-fiddle.com/f/vMY3Srd2bG6f3NshvTp3w1/0

```
-- succeeds
SELECT CAST((1::INT4) AS INT2);

-- fails: `Query Error: error: smallint out of range`
SELECT CAST((327686::INT4) AS INT2);
```
am357 added a commit that referenced this issue Jul 29, 2024
Add more cast tests

```SQL
CREATE TABLE PETS (
    id INT4,
    breed STRING,
    tag INT2
)
```

Tests:
```SQL
-- #1 should succeed
CAST(true AS INT2) --

-- #2  should fail
CAST((s : STRING) AS LIST)

-- #3 should succeed
CAST((i : INT2) AS INT4)

-- #4 should succeed
CAST((i : INT4) AS INT2)
```

#### Background context
As part of a specification work, we want to make the behavior for the #4 more visible:

 From SQL-99 Section 6.22: <cast specification>:

```
 If SD (source data type) is exact numeric or approximate numeric, then
 Case:
   i) If there is a representation of SV (source value) in the data type TD (target data type) that does not lose any leading si-gnificant digits after rounding or truncating if necessary, then TV is that representation.
 The choice of whether to round or truncate is implementation-defined.
 ii) Otherwise, an exception condition is raised: data exception — numeric value out of
 range.
 ```

We can see this evaluation behavior in PostgresSQL v15:
Ref.: https://www.db-fiddle.com/f/vMY3Srd2bG6f3NshvTp3w1/0

```
-- succeeds
SELECT CAST((1::INT4) AS INT2);

-- fails: `Query Error: error: smallint out of range`
SELECT CAST((327686::INT4) AS INT2);
```
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

No branches or pull requests

3 participants