Skip to content

Commit

Permalink
Merge pull request #21106 from danhhz/partition_scans
Browse files Browse the repository at this point in the history
sqlccl: add a few more scans to allPartitioningTests
  • Loading branch information
danhhz authored Dec 29, 2017
2 parents b3a0e57 + cc8cb01 commit 1d1e1b0
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions pkg/ccl/sqlccl/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,36 @@ func allPartitioningTests(rng *rand.Rand) []partitioningTest {
},
scans: map[string]string{`b < 4`: `n1`, `b = 4`: `n2`, `b = 5`: `n3`, `b > 5`: `n1`},
},

{
name: `scans`,
schema: `CREATE TABLE %s (a INT PRIMARY KEY, b INT) PARTITION BY LIST (a) (
PARTITION p3p5 VALUES IN ((3), (5)),
PARTITION p4 VALUES IN (4),
PARTITION pd VALUES IN (DEFAULT)
)`,
configs: []string{`@primary:+n1`, `.p3p5:+n2`, `.p4:+n3`, `.pd:+n1`},
generatedSpans: []string{
` .pd /1-/1/3`,
`.p3p5 /1/3-/1/4`,
` .p4 /1/4-/1/5`,
`.p3p5 /1/5-/1/6`,
` .pd /1/6-/2`,
},
scans: map[string]string{
`a < 3`: `n1`,
`a = 3`: `n2`,
`a = 4`: `n3`,
`a = 5`: `n2`,
`a > 5`: `n1`,

`a = 3 OR a = 5`: `n2`,
`a IN ((3), (5))`: `n2`,
`(a, b) IN ((3, 7))`: `n2`,
`a IN (3) AND a > 2`: `n2`,
`a IN (3) AND a < 2`: `n2`,
},
},
}

const schemaFmt = `CREATE TABLE %%s (a %s PRIMARY KEY) PARTITION BY LIST (a) (PARTITION p VALUES IN (%s))`
Expand Down Expand Up @@ -722,9 +752,10 @@ func allPartitioningTests(rng *rand.Rand) []partitioningTest {
schema: fmt.Sprintf(schemaFmt, colType, escapedDatum),
configs: []string{`@primary:+n1`, `.p:+n2`},
scans: map[string]string{
fmt.Sprintf(`a < %s`, serializedDatum): `n1`,
fmt.Sprintf(`a = %s`, serializedDatum): `n2`,
fmt.Sprintf(`a > %s`, serializedDatum): `n1`,
fmt.Sprintf(`a < %s`, serializedDatum): `n1`,
fmt.Sprintf(`a = %s`, serializedDatum): `n2`,
fmt.Sprintf(`a IN (%s)`, serializedDatum): `n2`,
fmt.Sprintf(`a > %s`, serializedDatum): `n1`,
},
}
tests = append(tests, test)
Expand Down

0 comments on commit 1d1e1b0

Please sign in to comment.