aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/col_auto_test.go
blob: d930888f5f8d449f0781c870319244002127e9b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package proto

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestColAuto_Infer(t *testing.T) {
	for _, columnType := range []ColumnType{
		ColumnTypeString,
		ColumnTypeArray.Sub(ColumnTypeString),
		ColumnTypeArray.Sub(ColumnTypeLowCardinality.Sub(ColumnTypeString)),
		ColumnTypeDate,
		ColumnTypeDate32,
		ColumnTypeInt8,
		ColumnTypeInt16,
		ColumnTypeArray.Sub(ColumnTypeInt16),
		ColumnTypeNullable.Sub(ColumnTypeInt16),
		ColumnTypeInt32,
		ColumnTypeInt64,
		ColumnTypeInt128,
		ColumnTypeInt256,
		ColumnTypeUInt8,
		ColumnTypeUInt16,
		ColumnTypeUInt32,
		ColumnTypeUInt64,
		ColumnTypeUInt128,
		ColumnTypeUInt256,
		ColumnTypeFloat32,
		ColumnTypeFloat64,
		ColumnTypeIPv4,
		ColumnTypeIPv6,
		ColumnTypeLowCardinality.Sub(ColumnTypeString),
		ColumnTypeDateTime.Sub("Europe/Berlin"),
		ColumnTypeDateTime64.Sub("9"),
		"Map(String,String)",
		"Enum8('hello'=1,'world'=2)",
		"Enum16('hello'=-1,'world'=10)",
		"IntervalSecond",
		"IntervalMinute",
		ColumnType(IntervalHour.String()),
		ColumnTypeNothing,
		"Nullable(Nothing)",
		"Array(Nothing)",
	} {
		r := AutoResult("foo")
		require.NoError(t, r.Data.(Inferable).Infer(columnType))
		require.Equal(t, columnType, r.Data.Type())
		r.Data.Reset()
		require.Equal(t, 0, r.Data.Rows())
	}
}