Skip to content

Commit 94b14e3

Browse files
committed
Add Sedona Flink SQL module
1 parent d6ea87c commit 94b14e3

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.sedona.flink;
20+
21+
import java.util.Arrays;
22+
import java.util.Map;
23+
import java.util.Optional;
24+
import java.util.Set;
25+
import java.util.stream.Collectors;
26+
import java.util.stream.Stream;
27+
import org.apache.flink.table.functions.FunctionDefinition;
28+
import org.apache.flink.table.module.Module;
29+
30+
public class SedonaModule implements Module {
31+
32+
private final Map<String, FunctionDefinition> functions;
33+
34+
public SedonaModule() {
35+
Stream<FunctionDefinition> funcs = Arrays.stream(Catalog.getFuncs());
36+
Stream<FunctionDefinition> predicates = Arrays.stream(Catalog.getPredicates());
37+
38+
this.functions =
39+
Stream.concat(funcs, predicates)
40+
.collect(Collectors.toMap(func -> func.getClass().getSimpleName(), func -> func));
41+
}
42+
43+
@Override
44+
public Set<String> listFunctions() {
45+
return functions.keySet();
46+
}
47+
48+
@Override
49+
public Optional<FunctionDefinition> getFunctionDefinition(String name) {
50+
return Optional.ofNullable(functions.get(name));
51+
}
52+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.sedona.flink;
20+
21+
import java.util.Collections;
22+
import java.util.Set;
23+
import org.apache.flink.configuration.ConfigOption;
24+
import org.apache.flink.table.factories.ModuleFactory;
25+
import org.apache.flink.table.module.Module;
26+
27+
public class SedonaModuleFactory implements ModuleFactory {
28+
29+
public static final String IDENTIFIER = "sedona";
30+
31+
@Override
32+
public Module createModule(Context context) {
33+
return new SedonaModule();
34+
}
35+
36+
@Override
37+
public String factoryIdentifier() {
38+
return IDENTIFIER;
39+
}
40+
41+
@Override
42+
public Set<ConfigOption<?>> requiredOptions() {
43+
return Collections.emptySet();
44+
}
45+
46+
@Override
47+
public Set<ConfigOption<?>> optionalOptions() {
48+
return Collections.emptySet();
49+
}
50+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.apache.sedona.flink.SedonaModuleFactory

0 commit comments

Comments
 (0)