Skip to content

Commit bb5b2ce

Browse files
authored
Merge f8da40b into 7b78453
2 parents 7b78453 + f8da40b commit bb5b2ce

File tree

18 files changed

+516
-154
lines changed

18 files changed

+516
-154
lines changed

.github/workflows/conformance-report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Gradle
2424
uses: gradle/gradle-build-action@v2
2525
with:
26-
gradle-version: 7.5.1
26+
gradle-version: 8.7
2727
# Run the conformance tests and save to an Ion file.
2828
- name: gradle test of the conformance tests (can fail) and save to Ion file
2929
continue-on-error: true
@@ -65,7 +65,7 @@ jobs:
6565
- name: Setup Gradle
6666
uses: gradle/gradle-build-action@v2
6767
with:
68-
gradle-version: 7.5.1
68+
gradle-version: 8.7
6969
- name: Download `conformance_test_results.ion` from target branch
7070
uses: dawidd6/action-download-artifact@v2
7171
id: download-report

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
Thank you to all who have contributed!
2424
-->
2525

26-
## [Unreleased]
26+
## [0.14.6]
2727

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

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

3239
### Deprecated
3340

3441
### Fixed
42+
- Fixed classpath conflict for IsStaticTypeMeta
43+
- Fixes ANTLR parser grammar file naming.
3544

3645
### Removed
3746

@@ -40,6 +49,10 @@ Thank you to all who have contributed!
4049
### Contributors
4150
Thank you to all who have contributed!
4251

52+
- @rchowell
53+
- @alancai98
54+
- @johnedquinn
55+
4356
## [0.14.5]
4457

4558
### Added

docs/wiki/documentation/Functions.md

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ CHAR_LENGTH(null) -- `null`
2222
CHAR_LENGTH(missing) -- `null` (also returns `null`)
2323
```
2424

25+
26+
### BIT_LENGTH -- since v0.10.0
27+
28+
Returns the number of bits in the input string.
29+
30+
Signature
31+
: `BIT_LENGTH: String —> Int`
32+
33+
Header
34+
: `BIT_LENGTH(str)`
35+
36+
Examples
37+
:
38+
39+
```sql
40+
bit_length('jose') -- 32
41+
```
42+
2543
### CAST -- since v0.1.0
2644

2745
Given a value and a target data type, attempt to coerce the value to the target data type.
@@ -652,6 +670,90 @@ NULLIF(null, null) -- null
652670
NULLIF(missing, null) -- null
653671
NULLIF(missing, missing) -- null
654672
```
673+
674+
### OCTET_LENGTH -- since v0.10.0
675+
676+
Returns the number of bytes in the input string.
677+
678+
Signature
679+
: `OCTET_LENGTH: String —> Int`
680+
681+
Header
682+
: `OCTET_LENGTH(str)`
683+
684+
Examples
685+
:
686+
687+
```sql
688+
octet_length('jose') -- 4
689+
```
690+
691+
### OVERLAY -- since v0.10.0
692+
693+
OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
694+
starting position and a given numeric length, with another string (called the replacement string). When the length of
695+
the substring is zero, nothing is removed from the original string and the string returned by the
696+
function is the result of inserting the replacement string into the original string at the starting position.
697+
698+
Signature
699+
: `OVERLAY: String, String, Int —> String`
700+
701+
Header
702+
: `OVERLAY(str1 PLACING str2 FROM pos)`
703+
704+
Signature
705+
: `OVERLAY: String, String, Int, Int —> String`
706+
707+
Header
708+
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`
709+
710+
Examples
711+
:
712+
713+
```sql
714+
overlay('hello' placing '' from 1) -- "hello
715+
overlay('hello' placing '' from 2 for 3) -- "ho
716+
overlay('hello' placing '' from 2 for 4) -- "h
717+
overlay('hello' placing 'XX' from 1) -- "XXllo
718+
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
719+
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
720+
overlay('hello' placing 'XX' from 1 for 100) -- "XX
721+
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
722+
overlay('hello' placing 'XX' from 7) -- "helloXX
723+
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
724+
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
725+
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
726+
```
727+
728+
### POSITION -- since v0.10.0
729+
730+
Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
731+
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
732+
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric
733+
734+
Signature
735+
: `POSITION: String, String —> Int`
736+
737+
Header
738+
: `POSITION(str1 IN str2)`
739+
740+
Header
741+
: `POSITION(str1, str2)`
742+
743+
Examples
744+
:
745+
746+
```sql
747+
position('foo' in 'hello') -- 0
748+
position('' in 'hello') -- 1
749+
position('h' in 'hello') -- 1
750+
position('o' in 'hello') -- 5
751+
position('ll' in 'hello') -- 3
752+
position('lo' in 'hello') -- 4
753+
position('hello' in 'hello') -- 1
754+
position('xx' in 'xxyyxxyy') -- 1
755+
position('yy' in 'xxyyxxyy') -- 3
756+
```
655757

656758
### SUBSTRING -- since v0.1.0
657759

@@ -693,6 +795,29 @@ SUBSTRING("1", 1, 0) -- ""
693795
SUBSTRING("1", -4, 0) -- ""
694796
SUBSTRING("1234", 10, 10) -- ""
695797
```
798+
799+
### TEXT_REPLACE -- since v0.10.0
800+
801+
In `string`, replaces all occurrences of substring `from` with another string `to`.
802+
803+
Signature
804+
: `TEXT_REPLACE: String, String, String -> String`
805+
806+
Header
807+
: `TEXT_REPLACE(string, from, to)`
808+
809+
Examples
810+
:
811+
812+
```sql
813+
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
814+
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
815+
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
816+
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
817+
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
818+
text_replace('', 'abc', 'XX') -- ''
819+
text_replace('', '', 'XX') -- 'XX'
820+
```
696821

697822
### TO_STRING -- since v0.1.0
698823

@@ -1210,131 +1335,6 @@ pow(`nan`, 1) = `nan`
12101335
pow(1, `+inf`) = `nan`
12111336
```
12121337

1213-
### BIT_LENGTH -- since v0.10.0
1214-
1215-
Returns the number of bits in the input string.
1216-
1217-
Signature
1218-
: `BIT_LENGTH: String —> Int`
1219-
1220-
Header
1221-
: `BIT_LENGTH(str)`
1222-
1223-
Examples
1224-
:
1225-
1226-
```sql
1227-
bit_length('jose') -- 32
1228-
```
1229-
1230-
### OCTET_LENGTH -- since v0.10.0
1231-
1232-
Returns the number of bytes in the input string.
1233-
1234-
Signature
1235-
: `OCTET_LENGTH: String —> Int`
1236-
1237-
Header
1238-
: `OCTET_LENGTH(str)`
1239-
1240-
Examples
1241-
:
1242-
1243-
```sql
1244-
octet_length('jose') -- 4
1245-
```
1246-
1247-
### POSITION -- since v0.10.0
1248-
1249-
Position determines the first position (counting from 1), if any, at which one string, str1, occurs within
1250-
another, str2. If str1 is of length zero, then it occurs at position 1 (one) for any value of str2. If str1
1251-
does not occur in str2, then zero is returned. The declared type of a <position expression> is exact numeric
1252-
1253-
Signature
1254-
: `POSITION: String, String —> Int`
1255-
1256-
Header
1257-
: `POSITION(str1 IN str2)`
1258-
1259-
Header
1260-
: `POSITION(str1, str2)`
1261-
1262-
Examples
1263-
:
1264-
1265-
```sql
1266-
position('foo' in 'hello') -- 0
1267-
position('' in 'hello') -- 1
1268-
position('h' in 'hello') -- 1
1269-
position('o' in 'hello') -- 5
1270-
position('ll' in 'hello') -- 3
1271-
position('lo' in 'hello') -- 4
1272-
position('hello' in 'hello') -- 1
1273-
position('xx' in 'xxyyxxyy') -- 1
1274-
position('yy' in 'xxyyxxyy') -- 3
1275-
```
1276-
1277-
1278-
### OVERLAY -- since v0.10.0
1279-
1280-
OVERLAY modifies a string argument by replacing a given substring of the string, which is specified by a given numeric
1281-
starting position and a given numeric length, with another string (called the replacement string). When the length of
1282-
the substring is zero, nothing is removed from the original string and the string returned by the
1283-
function is the result of inserting the replacement string into the original string at the starting position.
1284-
1285-
Signature
1286-
: `OVERLAY: String, String, Int —> String`
1287-
1288-
Header
1289-
: `OVERLAY(str1 PLACING str2 FROM pos)`
1290-
1291-
Signature
1292-
: `OVERLAY: String, String, Int, Int —> String`
1293-
1294-
Header
1295-
: `OVERLAY(str1 PLACING str2 FROM pos FOR for)`
1296-
1297-
Examples
1298-
:
1299-
1300-
```sql
1301-
overlay('hello' placing '' from 1) -- "hello
1302-
overlay('hello' placing '' from 2 for 3) -- "ho
1303-
overlay('hello' placing '' from 2 for 4) -- "h
1304-
overlay('hello' placing 'XX' from 1) -- "XXllo
1305-
overlay('hello' placing 'XX' from 1 for 3) -- "XXlo
1306-
overlay('hello' placing 'XX' from 1 for 1) -- "XXello
1307-
overlay('hello' placing 'XX' from 1 for 100) -- "XX
1308-
overlay('hello' placing 'XX' from 1 for 0) -- "XXhello
1309-
overlay('hello' placing 'XX' from 7) -- "helloXX
1310-
overlay('hello' placing 'XX' from 100 for 100) -- "helloXX
1311-
overlay('hello' placing 'XX' from 2 for 1) -- "hXXllo
1312-
overlay('hello' placing 'XX' from 2 for 3) -- "hXXo
1313-
```
1314-
1315-
### TEXT_REPLACE -- since v0.10.0
1316-
1317-
In `string`, replaces all occurrences of substring `from` with another string `to`.
1318-
1319-
Signature
1320-
: `TEXT_REPLACE: String, String, String -> String`
1321-
1322-
Header
1323-
: `TEXT_REPLACE(string, from, to)`
1324-
1325-
Examples
1326-
:
1327-
1328-
```sql
1329-
text_replace('abcdefabcdef', 'cd', 'XX') -- 'abXXefabXXef'
1330-
text_replace('abcdefabcdef', 'xyz', 'XX') -- 'abcdefabcdef'
1331-
text_replace('abcdefabcdef', 'defab', '') -- 'abccdef'
1332-
text_replace('abcabcabcdef', 'abcabc', 'XXX') -- 'XXXabcdef'
1333-
text_replace('abcabcabcdef', '', 'X') -- 'XaXbXcXaXbXcXaXbXcXdXeXfX'
1334-
text_replace('', 'abc', 'XX') -- ''
1335-
text_replace('', '', 'XX') -- 'XX'
1336-
```
1337-
13381338
<!--
13391339
This is the template for writing documentations for an PartiQL built-in function.
13401340

partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import org.partiql.ast.builder.ast
2727
import org.partiql.ast.exprLit
2828
import org.partiql.value.PartiQLValueExperimental
2929
import org.partiql.value.boolValue
30+
import org.partiql.value.dateValue
31+
import org.partiql.value.datetime.DateTimeValue
32+
import org.partiql.value.datetime.TimeZone
3033
import org.partiql.value.decimalValue
3134
import org.partiql.value.float32Value
3235
import org.partiql.value.float64Value
@@ -39,6 +42,8 @@ import org.partiql.value.missingValue
3942
import org.partiql.value.nullValue
4043
import org.partiql.value.stringValue
4144
import org.partiql.value.symbolValue
45+
import org.partiql.value.timeValue
46+
import org.partiql.value.timestampValue
4247
import java.math.BigDecimal
4348
import java.math.BigInteger
4449
import kotlin.test.assertFails
@@ -406,6 +411,16 @@ class SqlDialectTest {
406411
expect("""hello""") {
407412
exprLit(symbolValue("hello"))
408413
},
414+
expect("DATE '0001-02-03'") {
415+
exprLit(dateValue(DateTimeValue.date(1, 2, 3)))
416+
},
417+
expect("TIME '01:02:03.456-00:30'") {
418+
exprLit(timeValue(DateTimeValue.time(1, 2, BigDecimal.valueOf(3.456), TimeZone.UtcOffset.of(-30))))
419+
},
420+
expect("TIMESTAMP '0001-02-03 04:05:06.78-00:30'") {
421+
exprLit(timestampValue(DateTimeValue.timestamp(1, 2, 3, 4, 5, BigDecimal.valueOf(6.78), TimeZone.UtcOffset.of(-30))))
422+
},
423+
409424
// expect("""{{ '''Hello''' '''World''' }}""") {
410425
// exprLit(clobValue("HelloWorld".toByteArray()))
411426
// },

0 commit comments

Comments
 (0)