-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Transform-V2][SqlTransform] Support Not Like Expression #5456
Changes from all commits
b9f8284
b88d766
cfe2c14
c4f83c3
9ba7417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.seatunnel.e2e.transform; | ||
|
||
import org.apache.seatunnel.e2e.common.container.TestContainer; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.TestTemplate; | ||
import org.testcontainers.containers.Container; | ||
|
||
import java.io.IOException; | ||
|
||
public class NotLikeFilterIT extends TestSuiteBase { | ||
|
||
@TestTemplate | ||
public void testSQLTransform(TestContainer container) throws IOException, InterruptedException { | ||
Container.ExecResult sqlNotLikeFilter = | ||
container.executeJob("/sql_transform/not_like_filter.conf"); | ||
Assertions.assertEquals(0, sqlNotLikeFilter.getExitCode()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
###### | ||
###### This config file is a demonstration of streaming processing in seatunnel config | ||
###### | ||
env { | ||
execution.parallelism = 1 | ||
job.mode = "BATCH" | ||
checkpoint.interval = 10000 | ||
} | ||
|
||
source { | ||
FakeSource { | ||
result_table_name = "fake" | ||
schema = { | ||
fields { | ||
id = "int" | ||
name = "string" | ||
age = "int" | ||
email = "string" | ||
} | ||
} | ||
rows = [ | ||
{fields = [1, "Joy Ding", 20, null], kind = INSERT} | ||
{fields = [2, "May Ding", 22, "[email protected]"], kind = INSERT} | ||
{fields = [3, "Kin Dom", 21, "[email protected]"], kind = INSERT} | ||
] | ||
} | ||
} | ||
|
||
transform { | ||
Sql { | ||
source_table_name = "fake" | ||
result_table_name = "fake1" | ||
query = "select id,name,age from fake where name not like '%Din_'" | ||
} | ||
} | ||
|
||
sink { | ||
Console { | ||
source_table_name = "fake1" | ||
} | ||
Assert { | ||
source_table_name = "fake1" | ||
rules = { | ||
field_rules = [ | ||
{ | ||
field_name = "name" | ||
field_type = "string" | ||
field_value = [ | ||
{equals_to = "Kin Dom"} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ private boolean likeExpr(LikeExpression likeExpression, Object[] inputFields) { | |
Pattern pattern = Pattern.compile(regex); | ||
Matcher matcher = pattern.matcher(leftVal.toString()); | ||
|
||
return matcher.matches(); | ||
return matcher.matches() ^ likeExpression.isNot(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we split There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary to add a not like expression, because that's where the SQL engine expresses the match and mismatch logic. I'm referring to the IN expression logic |
||
} | ||
|
||
private Pair<Object, Object> executeComparisonOperator( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add license header