#
# 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, "may_ding@apache.com"], kind = INSERT}
      {fields = [3, "Kin Dom", 21, "kin_dom@apache.com"], kind = INSERT}
    ]
  }
}

transform {
  Sql {
    source_table_name = "fake"
    result_table_name = "fake1"
    query = "select id,name,age from fake where id=1 and id!=0 and name<>'Kin Dom' and (age>=20 or age<22) and regexp_like(name, '[A-Z ]*') and id>0 and id>=1 and id in (1,2,3,4) and id not in (5,6,7) and name is not null and email is null and id<4 and id<=4"
  }
}

sink {
  Console {
    source_table_name = "fake1"
  }
  Assert {
    source_table_name = "fake1"
    rules =
      {
        row_rules = [
          {
            rule_type = MIN_ROW
            rule_value = 1
          },
          {
            rule_type = MAX_ROW
            rule_value = 1
          }
        ]
      }
  }
}