Skip to content

Commit 8c8ad78

Browse files
huangjw806ZENOTMEtabVersionTennyZhuang
authored
chore(cherry-pick): cherry-pick #7562 #7539 #7482 (#7582)
* fix(frontend): remove alias check (#7562) In the old version, we guarantee every column with a alias name, these behaviour caused the bug #7549. ### And why we have this guarantee: At that time, function didn't have a alias, to guarantee every function column have a column name, we enforce the user must specify column alias.(A rude solution) #6798 But now, we can derive function alias so that I think we can remove the alias check. After remove it, our behaviour will be compatiable with postgres: ``` test_db=> create table t1 as select 1; SELECT 1 test_db=> select * from t1; ?column? ---------- 1 (1 row) test_db=> create table t as select 1,2,3; ERROR: column "?column?" specified more than once test_db=> create table t as select 1 as a , 2 as b; SELECT 1 test_db=> select * from t; a | b ---+--- 1 | 2 (1 row) ``` Approved-By: st1page * fix: move install mysql-client to ci image (#7539) fix main aca7030 Approved-By: jon-chuang * build(*): bump toolchain to 2023-01-18 (#7482) * build(toolchain): bump toolchain to 2023-01-18 Signed-off-by: TennyZhuang <[email protected]> * revert deps Signed-off-by: TennyZhuang <[email protected]> * update futures-async-stream Signed-off-by: TennyZhuang <[email protected]> Signed-off-by: TennyZhuang <[email protected]> --------- Signed-off-by: TennyZhuang <[email protected]> Co-authored-by: ZENOTME <[email protected]> Co-authored-by: Bohan Zhang <[email protected]> Co-authored-by: TennyZhuang <[email protected]>
1 parent 42efd23 commit 8c8ad78

File tree

39 files changed

+60
-90
lines changed

39 files changed

+60
-90
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG RUST_TOOLCHAIN
66

77
RUN apt-get update -yy && \
88
DEBIAN_FRONTEND=noninteractive apt-get -y install make build-essential cmake protobuf-compiler curl parallel \
9-
openssl libssl-dev libsasl2-dev libcurl4-openssl-dev pkg-config bash openjdk-11-jdk wget unzip git tmux lld postgresql-client kafkacat \
9+
openssl libssl-dev libsasl2-dev libcurl4-openssl-dev pkg-config bash openjdk-11-jdk wget unzip git tmux lld postgresql-client kafkacat netcat mysql-client \
1010
maven -yy \
1111
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
1212

ci/build-ci-image.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export RUST_TOOLCHAIN=$(cat ../rust-toolchain)
1414
# !!! CHANGE THIS WHEN YOU WANT TO BUMP CI IMAGE !!! #
1515
# AND ALSO docker-compose.yml #
1616
######################################################
17-
export BUILD_ENV_VERSION=v20230116
17+
export BUILD_ENV_VERSION=v20230126
1818

1919
export BUILD_TAG="public.ecr.aws/x5u3w5h6/rw-build-env:${BUILD_ENV_VERSION}"
2020

ci/docker-compose.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ services:
3030
retries: 5
3131

3232
source-test-env:
33-
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230116
33+
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230126
3434
depends_on:
3535
- mysql
3636
- db
3737
volumes:
3838
- ..:/risingwave
3939

4040
sink-test-env:
41-
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230116
41+
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230126
4242
depends_on:
4343
- mysql
4444
- db
4545
volumes:
4646
- ..:/risingwave
4747

4848
rw-build-env:
49-
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230116
49+
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230126
5050
volumes:
5151
- ..:/risingwave
5252

5353
regress-test-env:
54-
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230116
54+
image: public.ecr.aws/x5u3w5h6/rw-build-env:v20230126
5555
depends_on:
5656
db:
5757
condition: service_healthy

ci/scripts/e2e-sink-test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ cargo make pre-start-dev
4343
cargo make link-all-in-one-binaries
4444

4545
# prepare environment mysql sink
46-
apt-get -y install mysql-client
4746
mysql --host=mysql --port=3306 -u root -p123456 -e "CREATE DATABASE IF NOT EXISTS test;"
4847
# grant access to `test` for ci test user
4948
mysql --host=mysql --port=3306 -u root -p123456 -e "GRANT ALL PRIVILEGES ON test.* TO 'mysqluser'@'%';"

ci/scripts/e2e-source-test.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ cargo make pre-start-dev
5151
cargo make link-all-in-one-binaries
5252

5353
echo "--- e2e, ci-1cn-1fe, mysql & postgres cdc"
54-
# install mysql client
55-
apt-get -y install mysql-client
54+
5655
# import data to mysql
5756
mysql --host=mysql --port=3306 -u root -p123456 < ./e2e_test/source/cdc/mysql_cdc.sql
5857

e2e_test/ddl/table.slt

+17-3
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,27 @@ statement error
126126
create table t (v1 varchar collate "en_US");
127127

128128
# Test create-table-as
129-
statement error alias must be specified
129+
statement ok
130130
create table t as select 1;
131131

132-
# FIXME: this should be supported
133-
statement error alias must be specified
132+
statement ok
133+
drop table t;
134+
135+
statement error
136+
create table t as select 1,2;
137+
138+
statement ok
139+
create table t as select 1 as a, 2 as b;
140+
141+
statement ok
142+
drop table t;
143+
144+
statement ok
134145
create table t(v1) as select 1;
135146

147+
statement ok
148+
drop table t;
149+
136150
statement ok
137151
create table t (v1 int,v2 int);
138152

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2022-12-12
1+
nightly-2023-01-18

src/batch/src/executor/join/local_lookup_join.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ mod tests {
553553
lookup_prefix_len: 1,
554554
chunk_builder: DataChunkBuilder::new(original_schema.data_types(), CHUNK_SIZE),
555555
schema: original_schema.clone(),
556-
output_indices: (0..original_schema.len()).into_iter().collect(),
556+
output_indices: (0..original_schema.len()).collect(),
557557
chunk_size: CHUNK_SIZE,
558558
identity: "TestLookupJoinExecutor".to_string(),
559559
}

src/batch/src/executor/join/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ use risingwave_common::types::{DataType, DatumRef};
3333
use risingwave_pb::plan_common::JoinType as JoinTypeProst;
3434

3535
use crate::error::BatchError;
36-
use crate::executor::join::JoinType::Inner;
37-
#[derive(Copy, Clone, Debug, PartialEq)]
36+
37+
#[derive(Copy, Clone, Debug, Default, PartialEq)]
3838
pub enum JoinType {
39+
#[default]
3940
Inner,
4041
LeftOuter,
4142
/// Semi join when probe side should output when matched
@@ -103,12 +104,6 @@ impl JoinType {
103104
}
104105
}
105106

106-
impl Default for JoinType {
107-
fn default() -> Self {
108-
Inner
109-
}
110-
}
111-
112107
/// The layout be like:
113108
///
114109
/// [ `left` chunk | `right` chunk ]

src/batch/src/executor/limit.rs

-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ mod tests {
166166
) {
167167
let col = create_column(
168168
(0..row_num)
169-
.into_iter()
170169
.map(|x| Some(x as i32))
171170
.collect_vec()
172171
.as_slice(),
@@ -281,7 +280,6 @@ mod tests {
281280
assert_eq!(visible.len(), row_num);
282281
let col0 = create_column(
283282
(0..row_num)
284-
.into_iter()
285283
.map(|x| Some(x as i32))
286284
.collect_vec()
287285
.as_slice(),

src/bench/s3_bench/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ async fn multi_part_upload(
225225
};
226226
let chunks = obj
227227
.chunks(part_size.as_u64() as usize)
228-
.into_iter()
229228
.map(|chunk| chunk.to_owned())
230229
.collect_vec();
231230

src/common/src/array/data_chunk.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,7 @@ impl DataChunk {
344344
/// `[c, b, a]`. If `column_mapping` is [2, 0], then the output will be `[c, a]`
345345
/// If the input mapping is identity mapping, no reorder will be performed.
346346
pub fn reorder_columns(self, column_mapping: &[usize]) -> Self {
347-
if column_mapping
348-
.iter()
349-
.copied()
350-
.eq((0..self.columns().len()).into_iter())
351-
{
347+
if column_mapping.iter().copied().eq(0..self.columns().len()) {
352348
return self;
353349
}
354350
let mut new_columns = Vec::with_capacity(column_mapping.len());

src/common/src/array/stream_chunk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl StreamChunk {
254254
if column_mapping
255255
.iter()
256256
.copied()
257-
.eq((0..self.data.columns().len()).into_iter())
257+
.eq(0..self.data.columns().len())
258258
{
259259
// no reorder is needed
260260
self

src/common/src/field_generator/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ pub trait NumericFieldSequenceGenerator {
6161
}
6262

6363
/// the way that datagen create the field data. such as 'sequence' or 'random'.
64+
#[derive(Default)]
6465
pub enum FieldKind {
6566
Sequence,
67+
#[default]
6668
Random,
6769
}
6870

69-
impl Default for FieldKind {
70-
fn default() -> Self {
71-
FieldKind::Random
72-
}
73-
}
74-
7571
pub enum FieldGeneratorImpl {
7672
I16Sequence(I16SequenceField),
7773
I32Sequence(I32SequenceField),

src/common/src/types/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ macro_rules! scalar_impl_hash {
802802
}
803803
}
804804

805-
#[expect(clippy::derive_hash_xor_eq)]
806805
impl Hash for ScalarImpl {
807806
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
808807
match self {

src/connector/src/sink/remote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ enum ResponseStreamImpl {
8484

8585
impl ResponseStreamImpl {
8686
pub async fn next(&mut self) -> Result<SinkResponse> {
87-
return match self {
87+
match self {
8888
ResponseStreamImpl::Grpc(ref mut response) => response
8989
.next()
9090
.await
@@ -95,7 +95,7 @@ impl ResponseStreamImpl {
9595
SinkError::Remote("response stream closed unexpectedly".to_string())
9696
})
9797
}
98-
};
98+
}
9999
}
100100
}
101101

src/connector/src/source/pulsar/enumerator/client.rs

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ impl SplitEnumerator for PulsarSplitEnumerator {
9292
let splits = if topic_metadata.partitions > 0 {
9393
// partitioned topic
9494
(0..topic_metadata.partitions as i32)
95-
.into_iter()
9695
.map(|p| PulsarSplit {
9796
topic: self.topic.sub_topic(p).unwrap(),
9897
start_offset: offset.clone(),

src/expr/src/vector_op/to_char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn compile_pattern_to_chrono(tmpl: &str) -> ChronoPattern {
6565
});
6666
ChronoPatternBuilder {
6767
tmpl: chrono_tmpl,
68-
items_builder: |tmpl| StrftimeItems::new(tmpl).into_iter().collect::<Vec<_>>(),
68+
items_builder: |tmpl| StrftimeItems::new(tmpl).collect::<Vec<_>>(),
6969
}
7070
.build()
7171
}

src/frontend/src/expr/type_inference/func.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ fn infer_struct_cast_target_type(
222222
}
223223
(l, r @ NestedType::Struct(_)) | (l @ NestedType::Struct(_), r) => {
224224
// If only one side is nested type, these two types can never be casted.
225-
return Err(ErrorCode::BindError(format!(
225+
Err(ErrorCode::BindError(format!(
226226
"cannot infer type because unmatched types: left={:?} right={:?}",
227227
l, r
228228
))
229-
.into());
229+
.into())
230230
}
231231
(NestedType::Type(l), NestedType::Type(r)) => {
232232
// If both sides are concrete types, try cast in either direction.

src/frontend/src/handler/create_index.rs

-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ fn assemble_materialize(
295295
)),
296296
Order::new(
297297
(0..index_columns.len())
298-
.into_iter()
299298
.map(FieldOrder::ascending)
300299
.collect(),
301300
),

src/frontend/src/handler/create_table_as.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use risingwave_pb::stream_plan::stream_fragment_graph::Parallelism;
1919
use risingwave_sqlparser::ast::{ColumnDef, ObjectName, Query, Statement};
2020

2121
use super::{HandlerArgs, RwPgResponse};
22-
use crate::binder::{BoundSetExpr, BoundStatement};
22+
use crate::binder::BoundStatement;
2323
use crate::handler::create_table::{gen_create_table_plan_without_bind, ColumnIdGenerator};
2424
use crate::handler::query::handle_query;
2525
use crate::{build_graph, Binder, OptimizerContext};
@@ -55,16 +55,6 @@ pub async fn handle_create_as(
5555
let mut binder = Binder::new(&session);
5656
let bound = binder.bind(Statement::Query(query.clone()))?;
5757
if let BoundStatement::Query(query) = bound {
58-
// Check if all expressions have an alias
59-
if let BoundSetExpr::Select(select) = &query.body {
60-
if select.aliases.iter().any(Option::is_none) {
61-
return Err(ErrorCode::BindError(
62-
"An alias must be specified for an expression".to_string(),
63-
)
64-
.into());
65-
}
66-
}
67-
6858
let mut col_id_gen = ColumnIdGenerator::new_initial();
6959

7060
// Create ColumnCatelog by Field
@@ -89,6 +79,7 @@ pub async fn handle_create_as(
8979
.into());
9080
}
9181

82+
// Override column name if it specified in creaet statement.
9283
columns.iter().enumerate().for_each(|(idx, column)| {
9384
column_descs[idx].name = column.name.real_value();
9485
});

src/frontend/src/optimizer/plan_node/generic/agg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<PlanRef: GenericPlanRef> GenericPlanNode for Agg<PlanRef> {
6666
}
6767

6868
fn logical_pk(&self) -> Option<Vec<usize>> {
69-
Some((0..self.group_key.len()).into_iter().collect_vec())
69+
Some((0..self.group_key.len()).collect_vec())
7070
}
7171

7272
fn ctx(&self) -> OptimizerContextRef {

src/frontend/src/optimizer/plan_node/logical_agg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ impl ToStream for LogicalAgg {
948948
// LogicalAgg.
949949
// Please note that the index of group key need not be changed.
950950

951-
let mut output_indices = (0..self.schema().len()).into_iter().collect_vec();
951+
let mut output_indices = (0..self.schema().len()).collect_vec();
952952
output_indices
953953
.iter_mut()
954954
.skip(self.group_key().len())

src/frontend/src/optimizer/plan_node/logical_hop_window.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl LogicalHopWindow {
4848
output_indices: Option<Vec<usize>>,
4949
) -> Self {
5050
// if output_indices is not specified, use default output_indices
51-
let output_indices = output_indices
52-
.unwrap_or_else(|| (0..input.schema().len() + 2).into_iter().collect_vec());
51+
let output_indices =
52+
output_indices.unwrap_or_else(|| (0..input.schema().len() + 2).collect_vec());
5353
let output_type = DataType::window_of(&time_col.data_type).unwrap();
5454
let original_schema: Schema = input
5555
.schema()

src/frontend/src/optimizer/plan_node/logical_join.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,7 @@ impl LogicalJoin {
536536
.map(|x| x.as_input_ref().unwrap().index)
537537
.collect_vec()
538538
} else {
539-
(0..logical_scan.output_col_idx().len())
540-
.into_iter()
541-
.collect_vec()
539+
(0..logical_scan.output_col_idx().len()).collect_vec()
542540
};
543541
let left_schema_len = logical_join.left().schema().len();
544542

src/frontend/src/optimizer/plan_node/logical_multi_join.rs

-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ impl LogicalMultiJoin {
360360
.cloned()
361361
.flat_map(|input_idx| {
362362
(0..self.inputs[input_idx].schema().len())
363-
.into_iter()
364363
.map(move |col_idx| self.inner_i2o_mappings[input_idx].map(col_idx))
365364
})
366365
.enumerate()

src/frontend/src/optimizer/plan_node/logical_scan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl LogicalScan {
116116
Self::new(
117117
table_name,
118118
is_sys_table,
119-
(0..table_desc.columns.len()).into_iter().collect(),
119+
(0..table_desc.columns.len()).collect(),
120120
table_desc,
121121
indexes,
122122
ctx,

src/frontend/src/optimizer/property/func_dep.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl FunctionalDependencySet {
297297
assert!(
298298
self.is_key_inner(&key),
299299
"{:?} is not a key!",
300-
key.ones().into_iter().collect_vec()
300+
key.ones().collect_vec()
301301
);
302302
let mut new_key = key.clone();
303303
for i in key.ones() {

0 commit comments

Comments
 (0)