Commit 834163c9 authored by Alfonso Subiotto Marqués's avatar Alfonso Subiotto Marqués Committed by GitHub

Revert "release-19.2: colexec: skip over unneeded columns with unknown types in cfetcher"

parent c85d435c
......@@ -64,8 +64,7 @@ func BatchSize() uint16 {
return batchSize
}
// NewMemBatch allocates a new in-memory Batch. A coltypes.Unknown type
// will create a placeholder Vec that may not be accessed.
// NewMemBatch allocates a new in-memory Batch.
// TODO(jordan): pool these allocations.
func NewMemBatch(types []coltypes.T) Batch {
return NewMemBatchWithSize(types, int(BatchSize()))
......@@ -180,9 +179,7 @@ func (m *MemBatch) Reset(types []coltypes.T, length int) {
func (m *MemBatch) ResetInternalBatch() {
m.SetSelection(false)
for _, v := range m.b {
if v.Type() != coltypes.Unhandled {
v.Nulls().UnsetNulls()
}
v.Nulls().UnsetNulls()
if v.Type() == coltypes.Bytes {
v.Bytes().Reset()
}
......
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package coldata
import (
"time"
"github.com/cockroachdb/apd"
"github.com/cockroachdb/cockroach/pkg/col/coltypes"
)
// unknown is a Vec that represents an unhandled type. Used when a batch needs a placeholder Vec.
type unknown struct{}
func (u unknown) Type() coltypes.T {
return coltypes.Unhandled
}
func (u unknown) Bool() []bool {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Int16() []int16 {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Int32() []int32 {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Int64() []int64 {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Float64() []float64 {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Bytes() *Bytes {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Decimal() []apd.Decimal {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Timestamp() []time.Time {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Col() interface{} {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) SetCol(interface{}) {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) _TemplateType() []interface{} {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Append(SliceArgs) {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Copy(CopySliceArgs) {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Slice(colType coltypes.T, start uint64, end uint64) Vec {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) PrettyValueAt(idx uint16, colType coltypes.T) string {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) MaybeHasNulls() bool {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) Nulls() *Nulls {
panic("Vec is of unknown type and should not be accessed")
}
func (u unknown) SetNulls(*Nulls) {
panic("Vec is of unknown type and should not be accessed")
}
......@@ -156,8 +156,6 @@ func NewMemColumn(t coltypes.T, n int) Vec {
return &memColumn{t: t, col: make([]apd.Decimal, n), nulls: nulls}
case coltypes.Timestamp:
return &memColumn{t: t, col: make([]time.Time, n), nulls: nulls}
case coltypes.Unhandled:
return unknown{}
default:
panic(fmt.Sprintf("unhandled type %s", t))
}
......
......@@ -57,6 +57,9 @@ type cTableInfo struct {
// schema changes.
cols []sqlbase.ColumnDescriptor
// The exec types corresponding to the table columns in cols.
typs []coltypes.T
// The ordered list of ColumnIDs that are required.
neededColsList []int
......@@ -264,9 +267,7 @@ func (rf *cFetcher) Init(
typs := make([]coltypes.T, len(colDescriptors))
for i := range typs {
typs[i] = typeconv.FromColumnType(&colDescriptors[i].Type)
if typs[i] == coltypes.Unhandled && tableArgs.ValNeededForCol.Contains(i) {
// Only return an error if the type is unhandled and needed. If not needed,
// a placeholder Vec will be created.
if typs[i] == coltypes.Unhandled {
return errors.Errorf("unhandled type %+v", &colDescriptors[i].Type)
}
}
......@@ -277,6 +278,7 @@ func (rf *cFetcher) Init(
index: tableArgs.Index,
isSecondaryIndex: tableArgs.IsSecondaryIndex,
cols: colDescriptors,
typs: typs,
// These slice fields might get re-allocated below, so reslice them from
// the old table here in case they've got enough capacity already.
......@@ -592,10 +594,8 @@ func (rf *cFetcher) NextBatch(ctx context.Context) (coldata.Batch, error) {
rf.machine.state[0] = stateDecodeFirstKVOfRow
case stateResetBatch:
for _, colvec := range rf.machine.colvecs {
if colvec.Type() != coltypes.Unhandled {
colvec.Nulls().UnsetNulls()
}
for i := range rf.machine.colvecs {
rf.machine.colvecs[i].Nulls().UnsetNulls()
}
rf.machine.batch.ResetInternalBatch()
rf.shiftState()
......
......@@ -66,8 +66,6 @@ func EstimateBatchSizeBytes(vecTypes []coltypes.T, batchLength int) int {
// significantly overestimate.
// TODO(yuzefovich): figure out whether the caching does take place.
acc += sizeOfTime
case coltypes.Unhandled:
// Placeholder coldata.Vecs of unknown types are allowed.
default:
execerror.VectorizedInternalPanic(fmt.Sprintf("unhandled type %s", t))
}
......
......@@ -55,53 +55,7 @@ SELECT * FROM all_types ORDER BY 1
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
false 123 2019-10-22 00:00:00 +0000 +0000 1.23 123 123 123 123 1.23 123 63616665-6630-3064-6465-616462656562 2001-01-18 01:00:00.001 +0000 +0000
statement ok
CREATE TABLE skip_unneeded_cols (
_id UUID,
_id2 INT8,
_float FLOAT8,
_unsupported1 INT ARRAY,
_bool BOOL,
_unsupported2 INT ARRAY,
_bool2 BOOL,
PRIMARY KEY(_id, _id2)
)
statement ok
INSERT INTO skip_unneeded_cols VALUES ('63616665-6630-3064-6465-616462656562', 1, '1.2', NULL, true, NULL, false)
statement ok
SET vectorize=experimental_always
statement error pq: unable to vectorize execution plan: unhandled type int\[\]
SELECT _unsupported1 FROM skip_unneeded_cols
query IBB
SELECT _id2, _bool, _bool2 FROM skip_unneeded_cols
----
1 true false
statement ok
RESET vectorize
# This query uses a builtin that returns currently unsupported type
# (TimestampTZ). We're only interested in not getting an error. See #42871.
statement ok
SELECT experimental_strptime(_string, _string) IS NULL FROM all_types
statement ok
CREATE TABLE unsupported_type (id INT PRIMARY KEY, unsupported INT ARRAY)
statement ok
INSERT INTO unsupported_type (id) SELECT * FROM generate_series(1, 2000)
statement ok
SET vectorize=experimental_always
# This query makes sure that CFetcher when reading from a table with an
# unhandled type (that isn't needed) is reset correctly between batches.
statement ok
SELECT id FROM unsupported_type LIMIT 1 OFFSET 1100
statement ok
RESET vectorize
......@@ -658,7 +658,7 @@ query TTTTT
EXPLAIN (TYPES) SELECT b FROM computed ORDER BY b
----
· distributed false · ·
· vectorized true · ·
· vectorized false · ·
scan · · (b string) +b
· table [email protected]_b_idx · ·
· spans ALL · ·
......@@ -899,7 +899,7 @@ query TTTTT
EXPLAIN (TYPES) SELECT i FROM num WHERE i = -1:::INT
----
· distributed false · ·
· vectorized true · ·
· vectorized false · ·
scan · · (i int) ·
· table [email protected]_i_key · ·
· spans /-1-/0 · ·
......@@ -908,7 +908,7 @@ query TTTTT
EXPLAIN (TYPES) SELECT f FROM num WHERE f = -1:::FLOAT
----
· distributed false · ·
· vectorized true · ·
· vectorized false · ·
scan · · (f float) ·
· table [email protected]_f_key · ·
· spans /-1-/-1/PrefixEnd · ·
......@@ -917,7 +917,7 @@ query TTTTT
EXPLAIN (TYPES) SELECT d FROM num WHERE d = -1:::DECIMAL
----
· distributed false · ·
· vectorized true · ·
· vectorized false · ·
scan · · (d decimal) ·
· table [email protected]_d_key · ·
· spans /-1-/-1/PrefixEnd · ·
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment