Skip to content

Commit

Permalink
Merge pull request #1495 from partiql/temp-v0.14.6
Browse files Browse the repository at this point in the history
Picks commits from main to include in 0.14.6
  • Loading branch information
rchowell authored Jun 26, 2024
2 parents 7b78453 + f8da40b commit 0066d2a
Show file tree
Hide file tree
Showing 18 changed files with 516 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/conformance-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.5.1
gradle-version: 8.7
# Run the conformance tests and save to an Ion file.
- name: gradle test of the conformance tests (can fail) and save to Ion file
continue-on-error: true
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.5.1
gradle-version: 8.7
- name: Download `conformance_test_results.ion` from target branch
uses: dawidd6/action-download-artifact@v2
id: download-report
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Thank you to all who have contributed!
-->

## [Unreleased]
## [0.14.6]

### Added
- Adds `PartiQLValueTextWriter` implementation of date, time, and timestamp values
- Shades ANTLR dependency to avoid dependency conflicts.

### Changed
- **Behavioral change**: The `INTEGER/INT` type is now an alias to the `INT4` type. Previously the INTEGER type was
unconstrained which is not SQL-conformant and is causing issues in integrating with other systems. This release makes
INTEGER an alias for INT4 which is the internal type name. In a later release, we will make INTEGER the default 32-bit
integer with INT/INT4/INTEGER4 being aliases per other systems. This change only applies to
org.partiql.parser.PartiQLParser, not the org.partiql.lang.syntax.PartiQLParser.

### Deprecated

### Fixed
- Fixed classpath conflict for IsStaticTypeMeta
- Fixes ANTLR parser grammar file naming.

### Removed

Expand All @@ -40,6 +49,10 @@ Thank you to all who have contributed!
### Contributors
Thank you to all who have contributed!

- @rchowell
- @alancai98
- @johnedquinn

## [0.14.5]

### Added
Expand Down
250 changes: 125 additions & 125 deletions docs/wiki/documentation/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ CHAR_LENGTH(null) -- `null`
CHAR_LENGTH(missing) -- `null` (also returns `null`)
```


### BIT_LENGTH -- since v0.10.0

Returns the number of bits in the input string.

Signature
: `BIT_LENGTH: String —> Int`

Header
: `BIT_LENGTH(str)`

Examples
:

```sql
bit_length('jose') -- 32
```

### CAST -- since v0.1.0

Given a value and a target data type, attempt to coerce the value to the target data type.
Expand Down Expand Up @@ -652,6 +670,90 @@ NULLIF(null, null) -- null
NULLIF(missing, null) -- null
NULLIF(missing, missing) -- null
```

### OCTET_LENGTH -- since v0.10.0

Returns the number of bytes in the input string.

Signature
: `OCTET_LENGTH: String —> Int`

Header
: `OCTET_LENGTH(str)`

Examples
:

```sql
octet_length('jose') -- 4
```

### OVERLAY -- since v0.10.0

OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
starting position and a given numeric length, with another string (called the replacement string). When the length of
the substring is zero, nothing is removed from the original string and the string returned by the
function is the result of inserting the replacement string into the original string at the starting position.

Signature
: `OVERLAY: String, String, Int —> String`

Header
: `OVERLAY(str1 PLACING str2 FROM pos)`

Signature
: `OVERLAY: String, String, Int, Int —> String`

Header
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`

Examples
:

```sql
overlay('hello' placing '' from 1) -- "hello
overlay('hello' placing '' from 2 for 3) -- "ho
overlay('hello' placing '' from 2 for 4) -- "h
overlay('hello' placing 'XX' from 1) -- "XXllo
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
overlay('hello' placing 'XX' from 1 for 100) -- "XX
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
overlay('hello' placing 'XX' from 7) -- "helloXX
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
```

### POSITION -- since v0.10.0

Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric

Signature
: `POSITION: String, String —> Int`

Header
: `POSITION(str1 IN str2)`

Header
: `POSITION(str1, str2)`

Examples
:

```sql
position('foo' in 'hello') -- 0
position('' in 'hello') -- 1
position('h' in 'hello') -- 1
position('o' in 'hello') -- 5
position('ll' in 'hello') -- 3
position('lo' in 'hello') -- 4
position('hello' in 'hello') -- 1
position('xx' in 'xxyyxxyy') -- 1
position('yy' in 'xxyyxxyy') -- 3
```

### SUBSTRING -- since v0.1.0

Expand Down Expand Up @@ -693,6 +795,29 @@ SUBSTRING("1", 1, 0) -- ""
SUBSTRING("1", -4, 0) -- ""
SUBSTRING("1234", 10, 10) -- ""
```

### TEXT_REPLACE -- since v0.10.0

In `string`, replaces all occurrences of substring `from` with another string `to`.

Signature
: `TEXT_REPLACE: String, String, String -> String`

Header
: `TEXT_REPLACE(string, from, to)`

Examples
:

```sql
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
text_replace('', 'abc', 'XX') -- ''
text_replace('', '', 'XX') -- 'XX'
```

### TO_STRING -- since v0.1.0

Expand Down Expand Up @@ -1210,131 +1335,6 @@ pow(`nan`, 1) = `nan`
pow(1, `+inf`) = `nan`
```

### BIT_LENGTH -- since v0.10.0

Returns the number of bits in the input string.

Signature
: `BIT_LENGTH: String —> Int`

Header
: `BIT_LENGTH(str)`

Examples
:

```sql
bit_length('jose') -- 32
```

### OCTET_LENGTH -- since v0.10.0

Returns the number of bytes in the input string.

Signature
: `OCTET_LENGTH: String —> Int`

Header
: `OCTET_LENGTH(str)`

Examples
:

```sql
octet_length('jose') -- 4
```

### POSITION -- since v0.10.0

Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric

Signature
: `POSITION: String, String —> Int`

Header
: `POSITION(str1 IN str2)`

Header
: `POSITION(str1, str2)`

Examples
:

```sql
position('foo' in 'hello') -- 0
position('' in 'hello') -- 1
position('h' in 'hello') -- 1
position('o' in 'hello') -- 5
position('ll' in 'hello') -- 3
position('lo' in 'hello') -- 4
position('hello' in 'hello') -- 1
position('xx' in 'xxyyxxyy') -- 1
position('yy' in 'xxyyxxyy') -- 3
```


### OVERLAY -- since v0.10.0

OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
starting position and a given numeric length, with another string (called the replacement string). When the length of
the substring is zero, nothing is removed from the original string and the string returned by the
function is the result of inserting the replacement string into the original string at the starting position.

Signature
: `OVERLAY: String, String, Int —> String`

Header
: `OVERLAY(str1 PLACING str2 FROM pos)`

Signature
: `OVERLAY: String, String, Int, Int —> String`

Header
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`

Examples
:

```sql
overlay('hello' placing '' from 1) -- "hello
overlay('hello' placing '' from 2 for 3) -- "ho
overlay('hello' placing '' from 2 for 4) -- "h
overlay('hello' placing 'XX' from 1) -- "XXllo
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
overlay('hello' placing 'XX' from 1 for 100) -- "XX
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
overlay('hello' placing 'XX' from 7) -- "helloXX
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
```

### TEXT_REPLACE -- since v0.10.0

In `string`, replaces all occurrences of substring `from` with another string `to`.

Signature
: `TEXT_REPLACE: String, String, String -> String`

Header
: `TEXT_REPLACE(string, from, to)`

Examples
:

```sql
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
text_replace('', 'abc', 'XX') -- ''
text_replace('', '', 'XX') -- 'XX'
```

<!--
This is the template for writing documentations for an PartiQL built-in function.
Expand Down
15 changes: 15 additions & 0 deletions partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import org.partiql.ast.builder.ast
import org.partiql.ast.exprLit
import org.partiql.value.PartiQLValueExperimental
import org.partiql.value.boolValue
import org.partiql.value.dateValue
import org.partiql.value.datetime.DateTimeValue
import org.partiql.value.datetime.TimeZone
import org.partiql.value.decimalValue
import org.partiql.value.float32Value
import org.partiql.value.float64Value
Expand All @@ -39,6 +42,8 @@ import org.partiql.value.missingValue
import org.partiql.value.nullValue
import org.partiql.value.stringValue
import org.partiql.value.symbolValue
import org.partiql.value.timeValue
import org.partiql.value.timestampValue
import java.math.BigDecimal
import java.math.BigInteger
import kotlin.test.assertFails
Expand Down Expand Up @@ -406,6 +411,16 @@ class SqlDialectTest {
expect("""hello""") {
exprLit(symbolValue("hello"))
},
expect("DATE '0001-02-03'") {
exprLit(dateValue(DateTimeValue.date(1, 2, 3)))
},
expect("TIME '01:02:03.456-00:30'") {
exprLit(timeValue(DateTimeValue.time(1, 2, BigDecimal.valueOf(3.456), TimeZone.UtcOffset.of(-30))))
},
expect("TIMESTAMP '0001-02-03 04:05:06.78-00:30'") {
exprLit(timestampValue(DateTimeValue.timestamp(1, 2, 3, 4, 5, BigDecimal.valueOf(6.78), TimeZone.UtcOffset.of(-30))))
},

// expect("""{{ '''Hello''' '''World''' }}""") {
// exprLit(clobValue("HelloWorld".toByteArray()))
// },
Expand Down
Loading

0 comments on commit 0066d2a

Please sign in to comment.