Skip to content

Commit 850af06

Browse files
committed
fix integration test.
1 parent cfcc21b commit 850af06

File tree

6 files changed

+41
-105
lines changed

6 files changed

+41
-105
lines changed

common_types/src/column.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use arrow::{
1818
datatypes::{DataType, Int32Type, TimeUnit},
1919
error::ArrowError,
2020
};
21+
use bytes_ext::Bytes;
2122
use datafusion::physical_plan::{expressions::cast_column, ColumnarValue};
2223
use paste::paste;
2324
use snafu::{Backtrace, OptionExt, ResultExt, Snafu};

common_types/src/datum.rs

+36-98
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ impl Datum {
12341234
}
12351235
}
12361236

1237-
<<<<<<< HEAD
12381237
pub fn from_scalar_value(val: &ScalarValue) -> Option<Self> {
12391238
match val {
12401239
ScalarValue::Boolean(v) => v.map(Datum::Boolean),
@@ -1258,54 +1257,6 @@ impl Datum {
12581257
.map(|v| Datum::Varbinary(Bytes::copy_from_slice(v.as_slice()))),
12591258
ScalarValue::TimestampMillisecond(v, _) => {
12601259
v.map(|v| Datum::Timestamp(Timestamp::new(v)))
1261-
=======
1262-
pub fn from_scalar_value(val: &ScalarValue) -> Option<Self> {
1263-
match val {
1264-
ScalarValue::Boolean(v) => v.map(Datum::Boolean),
1265-
ScalarValue::Float32(v) => v.map(Datum::Float),
1266-
ScalarValue::Float64(v) => v.map(Datum::Double),
1267-
ScalarValue::Int8(v) => v.map(Datum::Int8),
1268-
ScalarValue::Int16(v) => v.map(Datum::Int16),
1269-
ScalarValue::Int32(v) => v.map(Datum::Int32),
1270-
ScalarValue::Int64(v) => v.map(Datum::Int64),
1271-
ScalarValue::UInt8(v) => v.map(Datum::UInt8),
1272-
ScalarValue::UInt16(v) => v.map(Datum::UInt16),
1273-
ScalarValue::UInt32(v) => v.map(Datum::UInt32),
1274-
ScalarValue::UInt64(v) => v.map(Datum::UInt64),
1275-
ScalarValue::Utf8(v) | ScalarValue::LargeUtf8(v) => v
1276-
.as_ref()
1277-
.map(|v| Datum::String(StringBytes::copy_from_str(v.as_str()))),
1278-
ScalarValue::Binary(v)
1279-
| ScalarValue::FixedSizeBinary(_, v)
1280-
| ScalarValue::LargeBinary(v) => v
1281-
.as_ref()
1282-
.map(|v| Datum::Varbinary(Bytes::copy_from_slice(v.as_slice()))),
1283-
ScalarValue::TimestampMillisecond(v, _) => {
1284-
v.map(|v| Datum::Timestamp(Timestamp::new(v)))
1285-
}
1286-
ScalarValue::Date32(v) => v.map(Datum::Date),
1287-
ScalarValue::Time64Nanosecond(v) => v.map(Datum::Time),
1288-
ScalarValue::Dictionary(_, literal) => Datum::from_scalar_value(literal),
1289-
ScalarValue::List(_, _)
1290-
| ScalarValue::Date64(_)
1291-
| ScalarValue::Time32Second(_)
1292-
| ScalarValue::Time32Millisecond(_)
1293-
| ScalarValue::Time64Microsecond(_)
1294-
| ScalarValue::TimestampSecond(_, _)
1295-
| ScalarValue::TimestampMicrosecond(_, _)
1296-
| ScalarValue::TimestampNanosecond(_, _)
1297-
| ScalarValue::IntervalYearMonth(_)
1298-
| ScalarValue::IntervalDayTime(_)
1299-
| ScalarValue::Struct(_, _)
1300-
| ScalarValue::Decimal128(_, _, _)
1301-
| ScalarValue::Null
1302-
| ScalarValue::IntervalMonthDayNano(_)
1303-
| ScalarValue::Fixedsizelist(_, _, _)
1304-
| ScalarValue::DurationSecond(_)
1305-
| ScalarValue::DurationMillisecond(_)
1306-
| ScalarValue::DurationMicrosecond(_)
1307-
| ScalarValue::DurationNanosecond(_) => None,
1308-
>>>>>>> d578bbe1 (bump datafusion version.)
13091260
}
13101261
ScalarValue::Date32(v) => v.map(Datum::Date),
13111262
ScalarValue::Time64Nanosecond(v) => v.map(Datum::Time),
@@ -1323,58 +1274,40 @@ impl Datum {
13231274
| ScalarValue::Struct(_, _)
13241275
| ScalarValue::Decimal128(_, _, _)
13251276
| ScalarValue::Null
1326-
| ScalarValue::IntervalMonthDayNano(_) => None,
1277+
| ScalarValue::IntervalMonthDayNano(_)
1278+
| ScalarValue::Fixedsizelist(_, _, _)
1279+
| ScalarValue::DurationSecond(_)
1280+
| ScalarValue::DurationMillisecond(_)
1281+
| ScalarValue::DurationMicrosecond(_)
1282+
| ScalarValue::DurationNanosecond(_) => None,
13271283
}
13281284
}
13291285
}
13301286

1331-
impl<'a> DatumView<'a> {
1332-
pub fn from_scalar_value(val: &'a ScalarValue) -> Option<Self> {
1333-
match val {
1334-
ScalarValue::Boolean(v) => v.map(DatumView::Boolean),
1335-
ScalarValue::Float32(v) => v.map(DatumView::Float),
1336-
ScalarValue::Float64(v) => v.map(DatumView::Double),
1337-
ScalarValue::Int8(v) => v.map(DatumView::Int8),
1338-
ScalarValue::Int16(v) => v.map(DatumView::Int16),
1339-
ScalarValue::Int32(v) => v.map(DatumView::Int32),
1340-
ScalarValue::Int64(v) => v.map(DatumView::Int64),
1341-
ScalarValue::UInt8(v) => v.map(DatumView::UInt8),
1342-
ScalarValue::UInt16(v) => v.map(DatumView::UInt16),
1343-
ScalarValue::UInt32(v) => v.map(DatumView::UInt32),
1344-
ScalarValue::UInt64(v) => v.map(DatumView::UInt64),
1345-
ScalarValue::Date32(v) => v.map(DatumView::Date),
1346-
ScalarValue::Time64Nanosecond(v) => v.map(DatumView::Time),
1347-
ScalarValue::Utf8(v) | ScalarValue::LargeUtf8(v) => {
1348-
v.as_ref().map(|v| DatumView::String(v.as_str()))
1349-
}
1350-
ScalarValue::Binary(v)
1351-
| ScalarValue::FixedSizeBinary(_, v)
1352-
| ScalarValue::LargeBinary(v) => {
1353-
v.as_ref().map(|v| DatumView::Varbinary(v.as_slice()))
1354-
}
1355-
ScalarValue::TimestampMillisecond(v, _) => {
1356-
v.map(|v| DatumView::Timestamp(Timestamp::new(v)))
1357-
}
1358-
ScalarValue::Dictionary(_, literal) => DatumView::from_scalar_value(literal),
1359-
ScalarValue::List(_, _)
1360-
| ScalarValue::Date64(_)
1361-
| ScalarValue::Time32Second(_)
1362-
| ScalarValue::Time32Millisecond(_)
1363-
| ScalarValue::Time64Microsecond(_)
1364-
| ScalarValue::TimestampSecond(_, _)
1365-
| ScalarValue::TimestampMicrosecond(_, _)
1366-
| ScalarValue::TimestampNanosecond(_, _)
1367-
| ScalarValue::IntervalYearMonth(_)
1368-
| ScalarValue::IntervalDayTime(_)
1369-
| ScalarValue::Struct(_, _)
1370-
| ScalarValue::Decimal128(_, _, _)
1371-
| ScalarValue::Null
1372-
| ScalarValue::IntervalMonthDayNano(_)
1373-
| ScalarValue::Fixedsizelist(_, _, _)
1374-
| ScalarValue::DurationSecond(_)
1375-
| ScalarValue::DurationMillisecond(_)
1376-
| ScalarValue::DurationMicrosecond(_)
1377-
| ScalarValue::DurationNanosecond(_) => None,
1287+
impl<'a> DatumView<'a> {
1288+
pub fn from_scalar_value(val: &'a ScalarValue) -> Option<Self> {
1289+
match val {
1290+
ScalarValue::Boolean(v) => v.map(DatumView::Boolean),
1291+
ScalarValue::Float32(v) => v.map(DatumView::Float),
1292+
ScalarValue::Float64(v) => v.map(DatumView::Double),
1293+
ScalarValue::Int8(v) => v.map(DatumView::Int8),
1294+
ScalarValue::Int16(v) => v.map(DatumView::Int16),
1295+
ScalarValue::Int32(v) => v.map(DatumView::Int32),
1296+
ScalarValue::Int64(v) => v.map(DatumView::Int64),
1297+
ScalarValue::UInt8(v) => v.map(DatumView::UInt8),
1298+
ScalarValue::UInt16(v) => v.map(DatumView::UInt16),
1299+
ScalarValue::UInt32(v) => v.map(DatumView::UInt32),
1300+
ScalarValue::UInt64(v) => v.map(DatumView::UInt64),
1301+
ScalarValue::Date32(v) => v.map(DatumView::Date),
1302+
ScalarValue::Time64Nanosecond(v) => v.map(DatumView::Time),
1303+
ScalarValue::Utf8(v) | ScalarValue::LargeUtf8(v) => {
1304+
v.as_ref().map(|v| DatumView::String(v.as_str()))
1305+
}
1306+
ScalarValue::Binary(v)
1307+
| ScalarValue::FixedSizeBinary(_, v)
1308+
| ScalarValue::LargeBinary(v) => v.as_ref().map(|v| DatumView::Varbinary(v.as_slice())),
1309+
ScalarValue::TimestampMillisecond(v, _) => {
1310+
v.map(|v| DatumView::Timestamp(Timestamp::new(v)))
13781311
}
13791312
ScalarValue::Dictionary(_, literal) => DatumView::from_scalar_value(literal),
13801313
ScalarValue::List(_, _)
@@ -1390,7 +1323,12 @@ impl Datum {
13901323
| ScalarValue::Struct(_, _)
13911324
| ScalarValue::Decimal128(_, _, _)
13921325
| ScalarValue::Null
1393-
| ScalarValue::IntervalMonthDayNano(_) => None,
1326+
| ScalarValue::IntervalMonthDayNano(_)
1327+
| ScalarValue::Fixedsizelist(_, _, _)
1328+
| ScalarValue::DurationSecond(_)
1329+
| ScalarValue::DurationMillisecond(_)
1330+
| ScalarValue::DurationMicrosecond(_)
1331+
| ScalarValue::DurationNanosecond(_) => None,
13941332
}
13951333
}
13961334
}

integration_tests/cases/common/dml/issue-59.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ GROUP BY id+1;
2525

2626
plan_type,plan,
2727
String("logical_plan"),String("Projection: group_alias_0 AS issue59.id + Int64(1), COUNT(alias1) AS COUNT(DISTINCT issue59.account)\n Aggregate: groupBy=[[group_alias_0]], aggr=[[COUNT(alias1)]]\n Projection: group_alias_0, alias1\n Aggregate: groupBy=[[CAST(issue59.id AS Int64) + Int64(1) AS group_alias_0, issue59.account AS alias1]], aggr=[[]]\n Projection: issue59.id, issue59.account\n TableScan: issue59 projection=[id, account]"),
28-
String("physical_plan"),String("ProjectionExec: expr=[group_alias_0@0 as issue59.id + Int64(1), COUNT(alias1)@1 as COUNT(DISTINCT issue59.account)]\n AggregateExec: mode=FinalPartitioned, gby=[group_alias_0@0 as group_alias_0], aggr=[COUNT(alias1)]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([Column { name: \"group_alias_0\", index: 0 }], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[group_alias_0@0 as group_alias_0], aggr=[COUNT(alias1)]\n ProjectionExec: expr=[group_alias_0@0 as group_alias_0, alias1@1 as alias1]\n AggregateExec: mode=FinalPartitioned, gby=[group_alias_0@0 as group_alias_0, alias1@1 as alias1], aggr=[]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([Column { name: \"group_alias_0\", index: 0 }, Column { name: \"alias1\", index: 1 }], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[CAST(id@0 AS Int64) + 1 as group_alias_0, account@1 as alias1], aggr=[]\n ProjectionExec: expr=[id@0 as id, account@1 as account]\n ScanTable: table=issue59, parallelism=8, order=None, \n"),
28+
String("physical_plan"),String("ProjectionExec: expr=[group_alias_0@0 as issue59.id + Int64(1), COUNT(alias1)@1 as COUNT(DISTINCT issue59.account)]\n AggregateExec: mode=FinalPartitioned, gby=[group_alias_0@0 as group_alias_0], aggr=[COUNT(alias1)]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([group_alias_0@0], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[group_alias_0@0 as group_alias_0], aggr=[COUNT(alias1)]\n ProjectionExec: expr=[group_alias_0@0 as group_alias_0, alias1@1 as alias1]\n AggregateExec: mode=FinalPartitioned, gby=[group_alias_0@0 as group_alias_0, alias1@1 as alias1], aggr=[]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([group_alias_0@0, alias1@1], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[CAST(id@0 AS Int64) + 1 as group_alias_0, account@1 as alias1], aggr=[]\n ProjectionExec: expr=[id@0 as id, account@1 as account]\n ScanTable: table=issue59, parallelism=8, order=None, \n"),
2929

3030

3131
DROP TABLE IF EXISTS issue59;

integration_tests/cases/common/dummy/select_1.result

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ Boolean(false),
2222

2323
SELECT NOT(1);
2424

25-
NOT Int64(1),
26-
Int64(-2),
27-
25+
Failed to execute query, err: Server(ServerError { code: 500, msg: "Failed to execute plan, sql: SELECT NOT(1);. Caused by: Internal error, msg:Failed to execute interpreter, err:Failed to execute select, err:Failed to execute logical plan, err:Failed to do logical optimization, err:DataFusion Failed to optimize logical plan, err:Optimizer rule 'simplify_expressions' failed\ncaused by\nInternal error: NOT 'Literal { value: Int64(1) }' can't be evaluated because the expression's type is Int64, not boolean or NULL. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker." })
2826

2927
SELECT TRUE;
3028

integration_tests/cases/common/dummy/select_1.sql

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ SELECT 1;
22

33
SELECT x;
44

5-
-- FIXME
65
SELECT 'a';
76

87
SELECT NOT(1=1);
98

10-
-- FIXME
9+
-- Revert to return error in https://github.com/apache/arrow-datafusion/pull/6599
1110
SELECT NOT(1);
1211

1312
SELECT TRUE;

integration_tests/cases/common/optimizer/optimizer.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ EXPLAIN SELECT max(value) AS c1, avg(value) AS c2 FROM `07_optimizer_t` GROUP BY
1010

1111
plan_type,plan,
1212
String("logical_plan"),String("Projection: MAX(07_optimizer_t.value) AS c1, AVG(07_optimizer_t.value) AS c2\n Aggregate: groupBy=[[07_optimizer_t.name]], aggr=[[MAX(07_optimizer_t.value), AVG(07_optimizer_t.value)]]\n Projection: 07_optimizer_t.name, 07_optimizer_t.value\n TableScan: 07_optimizer_t projection=[name, value]"),
13-
String("physical_plan"),String("ProjectionExec: expr=[MAX(07_optimizer_t.value)@1 as c1, AVG(07_optimizer_t.value)@2 as c2]\n AggregateExec: mode=FinalPartitioned, gby=[name@0 as name], aggr=[MAX(07_optimizer_t.value), AVG(07_optimizer_t.value)]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([Column { name: \"name\", index: 0 }], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[name@0 as name], aggr=[MAX(07_optimizer_t.value), AVG(07_optimizer_t.value)]\n ProjectionExec: expr=[name@0 as name, value@1 as value]\n ScanTable: table=07_optimizer_t, parallelism=8, order=None, \n"),
13+
String("physical_plan"),String("ProjectionExec: expr=[MAX(07_optimizer_t.value)@1 as c1, AVG(07_optimizer_t.value)@2 as c2]\n AggregateExec: mode=FinalPartitioned, gby=[name@0 as name], aggr=[MAX(07_optimizer_t.value), AVG(07_optimizer_t.value)]\n CoalesceBatchesExec: target_batch_size=8192\n RepartitionExec: partitioning=Hash([name@0], 8), input_partitions=8\n AggregateExec: mode=Partial, gby=[name@0 as name], aggr=[MAX(07_optimizer_t.value), AVG(07_optimizer_t.value)]\n ProjectionExec: expr=[name@0 as name, value@1 as value]\n ScanTable: table=07_optimizer_t, parallelism=8, order=None, \n"),
1414

1515

1616
DROP TABLE `07_optimizer_t`;

0 commit comments

Comments
 (0)