├── .github
└── workflows
│ └── maven-install.yml
├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src
├── main
├── 358
│ └── org.apache.paimon.trino
│ │ ├── DecimalUtils.java
│ │ ├── TrinoConnectorFactory.java
│ │ ├── TrinoHandleResolver.java
│ │ ├── TrinoMetadata.java
│ │ ├── TrinoPageSource.java
│ │ ├── TrinoSplitManager.java
│ │ └── TrinoSplitSource.java
├── 385
│ └── org.apache.paimon.trino
│ │ ├── DecimalUtils.java
│ │ ├── TrinoConnectorFactory.java
│ │ ├── TrinoMetadata.java
│ │ ├── TrinoPageSource.java
│ │ ├── TrinoSplitManager.java
│ │ └── TrinoSplitSource.java
├── 388
│ └── org
│ │ └── apache
│ │ └── paimon
│ │ └── trino
│ │ ├── DecimalUtils.java
│ │ ├── TrinoConnectorFactory.java
│ │ ├── TrinoMetadata.java
│ │ ├── TrinoPageSource.java
│ │ ├── TrinoSplitManager.java
│ │ └── TrinoSplitSource.java
├── java
│ └── org
│ │ └── apache
│ │ └── paimon
│ │ └── trino
│ │ ├── ClassLoaderUtils.java
│ │ ├── EncodingUtils.java
│ │ ├── FieldNameUtils.java
│ │ ├── TrinoColumnHandle.java
│ │ ├── TrinoConnector.java
│ │ ├── TrinoConnectorFactoryBase.java
│ │ ├── TrinoFilterConverter.java
│ │ ├── TrinoMetadataBase.java
│ │ ├── TrinoPageSourceBase.java
│ │ ├── TrinoPageSourceProvider.java
│ │ ├── TrinoPlugin.java
│ │ ├── TrinoSplit.java
│ │ ├── TrinoSplitManagerBase.java
│ │ ├── TrinoSplitSourceBase.java
│ │ ├── TrinoTableHandle.java
│ │ ├── TrinoTransactionHandle.java
│ │ └── TrinoTypeUtils.java
└── resources
│ └── META-INF
│ └── services
│ └── io.trino.spi.Plugin
└── test
├── java
└── org
│ └── apache
│ └── paimon
│ └── trino
│ ├── SimpleTableTestHelper.java
│ └── TestTrinoITCase.java
└── resources
└── log4j2-test.properties
/.github/workflows/maven-install.yml:
--------------------------------------------------------------------------------
1 | name: maven install
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - name: Checkout code
11 | uses: actions/checkout@v2
12 | - name: Set up JDK 11
13 | uses: actions/setup-java@v1
14 | with:
15 | java-version: 11
16 | - name: Build
17 | run: |
18 | mvn clean install
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .cache
2 | .classpath
3 | .idea
4 | .metadata
5 | .settings
6 | .project
7 | target
8 | .version.properties
9 | *.class
10 | *.iml
11 | *.swp
12 | *.jar
13 | *.zip
14 | *.log
15 | *.pyc
16 | .DS_Store
17 | *.ipr
18 | *.iws
19 | dependency-reduced-pom.xml
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # This has been migrated to https://github.com/apache/incubator-paimon-trino
2 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
23 | 4.0.0
24 |
25 |
26 | org.apache
27 | apache
28 | 23
29 |
30 |
31 | org.apache.paimon
32 | paimon-trino
33 | Paimon : Trino
34 | 0.4-SNAPSHOT
35 |
36 | jar
37 |
38 |
39 | 388
40 | 388
41 | 11
42 | 2.8.5
43 | 1.7.32
44 | 2.17.1
45 |
46 |
47 |
48 |
49 | org.apache.paimon
50 | paimon-bundle
51 | ${project.version}
52 |
53 |
54 |
55 | io.trino
56 | trino-plugin-toolkit
57 | ${trino.version}
58 | provided
59 |
60 |
61 |
62 | io.trino
63 | trino-spi
64 | ${trino.version}
65 | provided
66 |
67 |
68 |
69 | io.airlift
70 | configuration
71 | 216
72 |
73 |
74 |
75 | io.airlift
76 | slice
77 | 0.42
78 | provided
79 |
80 |
81 |
82 | org.apache.commons
83 | commons-lang3
84 | 3.3.2
85 |
86 |
87 |
88 | org.slf4j
89 | slf4j-api
90 | ${slf4j.version}
91 |
92 |
93 |
94 | org.apache.logging.log4j
95 | log4j-api
96 | ${log4j.version}
97 |
98 |
99 |
100 | org.apache.logging.log4j
101 | log4j-core
102 | ${log4j.version}
103 |
104 |
105 |
106 |
107 | org.apache.logging.log4j
108 | log4j-1.2-api
109 | ${log4j.version}
110 |
111 |
112 |
113 | com.google.guava
114 | guava
115 | 31.1-jre
116 |
117 |
118 |
119 |
120 | io.trino
121 | trino-client
122 | ${trino.version}
123 | test
124 |
125 |
126 |
127 | io.trino
128 | trino-main
129 | ${trino.version}
130 | test
131 |
132 |
133 | log4j
134 | log4j
135 |
136 |
137 | org.slf4j
138 | slf4j-log4j12
139 |
140 |
141 |
142 |
143 |
144 | io.trino
145 | trino-testing
146 | ${trino.version}
147 | test
148 |
149 |
150 |
151 | org.apache.hadoop
152 | hadoop-common
153 | ${hadoop.version}
154 | test
155 |
156 |
157 | log4j
158 | log4j
159 |
160 |
161 | org.slf4j
162 | slf4j-log4j12
163 |
164 |
165 |
166 |
167 |
168 | org.apache.hadoop
169 | hadoop-client
170 | ${hadoop.version}
171 | test
172 |
173 |
174 | log4j
175 | log4j
176 |
177 |
178 | org.slf4j
179 | slf4j-log4j12
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 | trino-358
189 |
190 | 358
191 | 358
192 | 11
193 |
194 |
195 |
196 | trino-385
197 |
198 | 385
199 | 385
200 | 11
201 |
202 |
203 |
204 | trino-391
205 |
206 | 391
207 | 388
208 | 17
209 |
210 |
211 |
212 | trino-409
213 |
214 | 409
215 | 388
216 | 17
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 | org.apache.maven.plugins
225 | maven-shade-plugin
226 |
227 |
228 | shade-flink
229 | package
230 |
231 | shade
232 |
233 |
234 |
235 |
236 | org.apache.paimon:paimon-bundle
237 | org.slf4j:slf4j-api
238 | org.xerial.snappy:snappy-java
239 | org.apache.commons:commons-lang3
240 | org.apache.logging.log4j:log4j-api
241 | org.apache.logging.log4j:log4j-core
242 | org.apache.logging.log4j:log4j-slf4j-impl
243 | org.apache.logging.log4j:log4j-1.2-api
244 | com.google.guava:guava
245 |
246 |
247 |
248 |
249 |
251 |
252 |
254 | Apache Paimon
255 | UTF-8
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 | org.codehaus.mojo
265 | build-helper-maven-plugin
266 |
267 |
268 | add-sources
269 | generate-sources
270 |
271 | add-source
272 |
273 |
274 |
275 | src/main/${trino.shade.version}
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 | org.apache.maven.plugins
287 | maven-compiler-plugin
288 | 3.8.0
289 |
290 | ${target.java.version}
291 | ${target.java.version}
292 |
293 | false
294 |
295 |
296 | -Xpkginfo:always
297 |
298 |
299 |
300 |
301 |
302 | org.apache.maven.plugins
303 | maven-enforcer-plugin
304 | 3.0.0-M1
305 |
306 |
307 |
308 |
309 | org.apache.maven.plugins
310 | maven-shade-plugin
311 | 3.1.1
312 |
313 |
314 |
315 |
316 | org.apache.maven.plugins
317 | maven-site-plugin
318 |
319 |
320 | attach-descriptor
321 | none
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/DecimalUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.airlift.slice.Slice;
22 | import java.math.BigInteger;
23 | import io.trino.spi.type.Decimals;
24 |
25 | public class DecimalUtils {
26 |
27 | public static BigInteger toBigInteger(Object value) {
28 | return Decimals.decodeUnscaledValue((Slice) value);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoConnectorFactory.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorFactory;
22 | import io.trino.spi.connector.ConnectorHandleResolver;
23 |
24 | /** Trino {@link ConnectorFactory}. */
25 | public class TrinoConnectorFactory extends TrinoConnectorFactoryBase {
26 |
27 | @Override
28 | public ConnectorHandleResolver getHandleResolver() {
29 | return new TrinoHandleResolver();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoHandleResolver.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ColumnHandle;
22 | import io.trino.spi.connector.ConnectorHandleResolver;
23 | import io.trino.spi.connector.ConnectorSplit;
24 | import io.trino.spi.connector.ConnectorTableHandle;
25 | import io.trino.spi.connector.ConnectorTransactionHandle;
26 |
27 | public class TrinoHandleResolver
28 | implements ConnectorHandleResolver
29 | {
30 | @Override
31 | public Class extends ConnectorTransactionHandle> getTransactionHandleClass()
32 | {
33 | return TrinoTransactionHandle.class;
34 | }
35 |
36 | @Override
37 | public Class extends ConnectorTableHandle> getTableHandleClass()
38 | {
39 | return TrinoTableHandle.class;
40 | }
41 |
42 | @Override
43 | public Class extends ColumnHandle> getColumnHandleClass()
44 | {
45 | return TrinoColumnHandle.class;
46 | }
47 |
48 | @Override
49 | public Class extends ConnectorSplit> getSplitClass()
50 | {
51 | return TrinoSplit.class;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoMetadata.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.options.Options;
22 |
23 | public class TrinoMetadata extends TrinoMetadataBase {
24 |
25 | public TrinoMetadata(Options catalogOptions) {
26 | super(catalogOptions);
27 | }
28 |
29 | @Override
30 | public boolean usesLegacyTableLayouts() {
31 | return false;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoPageSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ColumnHandle;
22 |
23 | import org.apache.paimon.data.InternalRow;
24 | import org.apache.paimon.reader.RecordReader;
25 |
26 | import java.util.List;
27 |
28 | public class TrinoPageSource extends TrinoPageSourceBase {
29 |
30 | public TrinoPageSource(RecordReader reader, List projectedColumns) {
31 | super(reader, projectedColumns);
32 | }
33 |
34 | @Override
35 | public long getSystemMemoryUsage() {
36 | return 0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoSplitManager.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorSession;
22 | import io.trino.spi.connector.ConnectorSplitSource;
23 | import io.trino.spi.connector.ConnectorTableHandle;
24 | import io.trino.spi.connector.ConnectorTransactionHandle;
25 | import io.trino.spi.connector.DynamicFilter;
26 |
27 | public class TrinoSplitManager extends TrinoSplitManagerBase {
28 |
29 | @Override
30 | public ConnectorSplitSource getSplits(
31 | ConnectorTransactionHandle transaction,
32 | ConnectorSession session,
33 | ConnectorTableHandle table,
34 | SplitSchedulingStrategy splitSchedulingStrategy,
35 | DynamicFilter dynamicFilter) {
36 | return getSplits(table, session);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/358/org.apache.paimon.trino/TrinoSplitSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorPartitionHandle;
22 |
23 | import java.util.List;
24 | import java.util.concurrent.CompletableFuture;
25 |
26 | public class TrinoSplitSource extends TrinoSplitSourceBase {
27 |
28 | public TrinoSplitSource(List splits) {
29 | super(splits);
30 | }
31 |
32 | @Override
33 | public CompletableFuture getNextBatch(
34 | ConnectorPartitionHandle partitionHandle, int maxSize) {
35 | return innerGetNextBatch(maxSize);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/DecimalUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.type.Int128;
22 | import java.math.BigInteger;
23 |
24 | public class DecimalUtils {
25 |
26 | public static BigInteger toBigInteger(Object value) {
27 | return ((Int128) value).toBigInteger();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/TrinoConnectorFactory.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | public class TrinoConnectorFactory extends TrinoConnectorFactoryBase {
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/TrinoMetadata.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.options.Options;
22 |
23 | public class TrinoMetadata extends TrinoMetadataBase {
24 |
25 | public TrinoMetadata(Options catalogOptions) {
26 | super(catalogOptions);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/TrinoPageSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ColumnHandle;
22 |
23 | import org.apache.paimon.data.InternalRow;
24 | import org.apache.paimon.reader.RecordReader;
25 |
26 | import java.util.List;
27 |
28 | public class TrinoPageSource extends TrinoPageSourceBase {
29 |
30 | public TrinoPageSource(RecordReader reader, List projectedColumns) {
31 | super(reader, projectedColumns);
32 | }
33 |
34 | @Override
35 | public long getMemoryUsage() {
36 | return 0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/TrinoSplitManager.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorSession;
22 | import io.trino.spi.connector.ConnectorSplitManager;
23 | import io.trino.spi.connector.ConnectorSplitSource;
24 | import io.trino.spi.connector.ConnectorTableHandle;
25 | import io.trino.spi.connector.ConnectorTransactionHandle;
26 | import io.trino.spi.connector.Constraint;
27 | import io.trino.spi.connector.DynamicFilter;
28 |
29 | public class TrinoSplitManager extends TrinoSplitManagerBase {
30 |
31 | @Override
32 | public ConnectorSplitSource getSplits(
33 | ConnectorTransactionHandle transaction,
34 | ConnectorSession session,
35 | ConnectorTableHandle table,
36 | ConnectorSplitManager.SplitSchedulingStrategy splitSchedulingStrategy,
37 | DynamicFilter dynamicFilter,
38 | Constraint constraint) {
39 | return getSplits(table, session);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/385/org.apache.paimon.trino/TrinoSplitSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorPartitionHandle;
22 |
23 |
24 | import java.util.List;
25 | import java.util.concurrent.CompletableFuture;
26 |
27 | public class TrinoSplitSource extends TrinoSplitSourceBase {
28 |
29 | public TrinoSplitSource(List splits) {
30 | super(splits);
31 | }
32 |
33 | @Override
34 | public CompletableFuture getNextBatch(ConnectorPartitionHandle partitionHandle, int maxSize) {
35 | return innerGetNextBatch(maxSize);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/DecimalUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.type.Int128;
22 | import java.math.BigInteger;
23 |
24 | public class DecimalUtils {
25 |
26 | public static BigInteger toBigInteger(Object value) {
27 | return ((Int128) value).toBigInteger();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/TrinoConnectorFactory.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | public class TrinoConnectorFactory extends TrinoConnectorFactoryBase {
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/TrinoMetadata.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.options.Options;
22 |
23 | public class TrinoMetadata extends TrinoMetadataBase {
24 |
25 | public TrinoMetadata(Options catalogOptions) {
26 | super(catalogOptions);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/TrinoPageSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ColumnHandle;
22 |
23 | import org.apache.paimon.data.InternalRow;
24 | import org.apache.paimon.reader.RecordReader;
25 |
26 | import java.util.List;
27 |
28 | public class TrinoPageSource extends TrinoPageSourceBase {
29 |
30 | public TrinoPageSource(RecordReader reader, List projectedColumns) {
31 | super(reader, projectedColumns);
32 | }
33 |
34 | @Override
35 | public long getMemoryUsage() {
36 | return 0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/TrinoSplitManager.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.ConnectorSession;
22 | import io.trino.spi.connector.ConnectorSplitSource;
23 | import io.trino.spi.connector.ConnectorTableHandle;
24 | import io.trino.spi.connector.ConnectorTransactionHandle;
25 | import io.trino.spi.connector.Constraint;
26 | import io.trino.spi.connector.DynamicFilter;
27 |
28 | public class TrinoSplitManager extends TrinoSplitManagerBase {
29 |
30 | @Override
31 | public ConnectorSplitSource getSplits(
32 | ConnectorTransactionHandle transaction,
33 | ConnectorSession session,
34 | ConnectorTableHandle table,
35 | DynamicFilter dynamicFilter,
36 | Constraint constraint) {
37 | return getSplits(table, session);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/388/org/apache/paimon/trino/TrinoSplitSource.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import java.util.List;
22 | import java.util.concurrent.CompletableFuture;
23 |
24 | public class TrinoSplitSource extends TrinoSplitSourceBase {
25 |
26 | public TrinoSplitSource(List splits) {
27 | super(splits);
28 | }
29 |
30 | @Override
31 | public CompletableFuture getNextBatch(int maxSize) {
32 | return innerGetNextBatch(maxSize);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/ClassLoaderUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import java.util.function.Supplier;
22 |
23 | /** Utils for {@link ClassLoader}. */
24 | public class ClassLoaderUtils {
25 |
26 | public static T runWithContextClassLoader(Supplier supplier, ClassLoader classLoader) {
27 | ClassLoader previous = Thread.currentThread().getContextClassLoader();
28 | Thread.currentThread().setContextClassLoader(classLoader);
29 | try {
30 | return supplier.get();
31 | } finally {
32 | Thread.currentThread().setContextClassLoader(previous);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/EncodingUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.utils.InstantiationUtil;
22 |
23 |
24 | import java.util.Base64;
25 |
26 | import static java.nio.charset.StandardCharsets.UTF_8;
27 |
28 | /** Utils for encoding. */
29 | public class EncodingUtils {
30 |
31 | private static final Base64.Encoder BASE64_ENCODER =
32 | java.util.Base64.getUrlEncoder().withoutPadding();
33 |
34 | private static final Base64.Decoder BASE64_DECODER = java.util.Base64.getUrlDecoder();
35 |
36 | public static String encodeObjectToString(T t) {
37 | try {
38 | byte[] bytes = InstantiationUtil.serializeObject(t);
39 | return new String(BASE64_ENCODER.encode(bytes), UTF_8);
40 | } catch (Exception e) {
41 | throw new RuntimeException(e);
42 | }
43 | }
44 |
45 | public static T decodeStringToObject(String encodedStr) {
46 | final byte[] bytes = BASE64_DECODER.decode(encodedStr.getBytes(UTF_8));
47 | try {
48 | return InstantiationUtil.deserializeObject(bytes, EncodingUtils.class.getClassLoader());
49 | } catch (Exception e) {
50 | throw new RuntimeException(e);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/FieldNameUtils.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.types.DataField;
22 | import org.apache.paimon.types.RowType;
23 |
24 |
25 | import java.util.List;
26 | import java.util.stream.Collectors;
27 |
28 | public class FieldNameUtils {
29 |
30 | public static List fieldNames(RowType rowType) {
31 | return rowType.getFields().stream()
32 | .map(DataField::name)
33 | .map(String::toLowerCase)
34 | .collect(Collectors.toList());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/TrinoColumnHandle.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import com.fasterxml.jackson.annotation.JsonCreator;
22 | import com.fasterxml.jackson.annotation.JsonProperty;
23 | import io.trino.spi.connector.ColumnHandle;
24 | import io.trino.spi.connector.ColumnMetadata;
25 | import io.trino.spi.type.Type;
26 |
27 | import org.apache.paimon.utils.JsonSerdeUtil;
28 | import org.apache.paimon.types.DataType;
29 | import org.apache.paimon.types.DataTypeJsonParser;
30 |
31 |
32 | import static java.util.Objects.requireNonNull;
33 |
34 | /** Trino {@link ColumnHandle}. */
35 | public final class TrinoColumnHandle implements ColumnHandle {
36 | private final String columnName;
37 | private final String typeString;
38 | private final Type trinoType;
39 |
40 | @JsonCreator
41 | public TrinoColumnHandle(
42 | @JsonProperty("columnName") String columnName,
43 | @JsonProperty("typeString") String typeString,
44 | @JsonProperty("trinoType") Type trinoType) {
45 | this.columnName = requireNonNull(columnName, "columnName is null");
46 | this.typeString = requireNonNull(typeString, "columnType is null");
47 | this.trinoType = requireNonNull(trinoType, "columnType is null");
48 | }
49 |
50 | public static TrinoColumnHandle of(String columnName, DataType columnType) {
51 | return new TrinoColumnHandle(
52 | columnName,
53 | JsonSerdeUtil.toJson(columnType),
54 | TrinoTypeUtils.fromFlinkType(columnType));
55 | }
56 |
57 | @JsonProperty
58 | public String getColumnName() {
59 | return columnName;
60 | }
61 |
62 | @JsonProperty
63 | public String getTypeString() {
64 | return typeString;
65 | }
66 |
67 | @JsonProperty
68 | public Type getTrinoType() {
69 | return trinoType;
70 | }
71 |
72 | public DataType logicalType() {
73 | return JsonSerdeUtil.fromJson(typeString, DataType.class);
74 | }
75 |
76 | public ColumnMetadata getColumnMetadata() {
77 | return new ColumnMetadata(columnName, trinoType);
78 | }
79 |
80 | @Override
81 | public int hashCode() {
82 | return columnName.hashCode();
83 | }
84 |
85 | @Override
86 | public boolean equals(Object obj) {
87 | if (this == obj) {
88 | return true;
89 | }
90 | if ((obj == null) || (getClass() != obj.getClass())) {
91 | return false;
92 | }
93 |
94 | TrinoColumnHandle other = (TrinoColumnHandle) obj;
95 | return columnName.equals(other.columnName);
96 | }
97 |
98 | @Override
99 | public String toString() {
100 | return "{"
101 | + "columnName='"
102 | + columnName
103 | + '\''
104 | + ", typeString='"
105 | + typeString
106 | + '\''
107 | + ", trinoType="
108 | + trinoType
109 | + '}';
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/TrinoConnector.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import io.trino.spi.connector.Connector;
22 | import io.trino.spi.connector.ConnectorTransactionHandle;
23 | import io.trino.spi.session.PropertyMetadata;
24 | import io.trino.spi.transaction.IsolationLevel;
25 | import org.apache.paimon.CoreOptions;
26 |
27 |
28 | import java.util.Arrays;
29 | import java.util.List;
30 |
31 | import static io.trino.spi.transaction.IsolationLevel.READ_COMMITTED;
32 | import static io.trino.spi.transaction.IsolationLevel.checkConnectorSupports;
33 | import static java.util.Objects.requireNonNull;
34 | import static org.apache.paimon.CoreOptions.SCAN_SNAPSHOT_ID;
35 | import static org.apache.paimon.CoreOptions.SCAN_TIMESTAMP_MILLIS;
36 | import static org.apache.paimon.trino.TrinoTableHandle.SCAN_TIMESTAMP;
37 | import static org.apache.paimon.trino.TrinoTableHandle.SCAN_SNAPSHOT;
38 |
39 | /** Trino {@link Connector}. */
40 | public class TrinoConnector implements Connector {
41 | private final TrinoMetadataBase trinoMetadata;
42 | private final TrinoSplitManagerBase trinoSplitManager;
43 | private final TrinoPageSourceProvider trinoPageSourceProvider;
44 |
45 | public TrinoConnector(
46 | TrinoMetadataBase trinoMetadata,
47 | TrinoSplitManagerBase trinoSplitManager,
48 | TrinoPageSourceProvider trinoPageSourceProvider) {
49 | this.trinoMetadata = requireNonNull(trinoMetadata, "jmxMetadata is null");
50 | this.trinoSplitManager = requireNonNull(trinoSplitManager, "jmxSplitManager is null");
51 | this.trinoPageSourceProvider =
52 | requireNonNull(trinoPageSourceProvider, "jmxRecordSetProvider is null");
53 | }
54 |
55 | @Override
56 | public ConnectorTransactionHandle beginTransaction(
57 | IsolationLevel isolationLevel, boolean readOnly) {
58 | checkConnectorSupports(READ_COMMITTED, isolationLevel);
59 | return TrinoTransactionHandle.INSTANCE;
60 | }
61 |
62 | @Override
63 | public TrinoMetadataBase getMetadata(ConnectorTransactionHandle transactionHandle) {
64 | return trinoMetadata;
65 | }
66 |
67 | @Override
68 | public TrinoSplitManagerBase getSplitManager() {
69 | return trinoSplitManager;
70 | }
71 |
72 | @Override
73 | public TrinoPageSourceProvider getPageSourceProvider() {
74 | return trinoPageSourceProvider;
75 | }
76 |
77 | @Override
78 | public List> getSessionProperties() {
79 | return Arrays.asList(
80 | PropertyMetadata.longProperty(
81 | SCAN_TIMESTAMP,
82 | SCAN_TIMESTAMP_MILLIS.description().toString(),
83 | null,
84 | true),
85 | PropertyMetadata.longProperty(
86 | SCAN_SNAPSHOT,
87 | SCAN_SNAPSHOT_ID.description().toString(),
88 | null,
89 | true)
90 | );
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/TrinoConnectorFactoryBase.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.options.Options;
22 |
23 | import java.util.Map;
24 |
25 | import io.trino.spi.connector.Connector;
26 | import io.trino.spi.connector.ConnectorContext;
27 | import io.trino.spi.connector.ConnectorFactory;
28 |
29 | /** Trino {@link ConnectorFactory}. */
30 | public abstract class TrinoConnectorFactoryBase implements ConnectorFactory {
31 | @Override
32 | public String getName() {
33 | return "paimon";
34 | }
35 |
36 | @Override
37 | public Connector create(
38 | String catalogName, Map config, ConnectorContext context) {
39 | return new TrinoConnector(
40 | new TrinoMetadata(Options.fromMap(config)),
41 | new TrinoSplitManager(),
42 | new TrinoPageSourceProvider());
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/paimon/trino/TrinoFilterConverter.java:
--------------------------------------------------------------------------------
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, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package org.apache.paimon.trino;
20 |
21 | import org.apache.paimon.data.BinaryString;
22 | import org.apache.paimon.data.Decimal;
23 | import org.apache.paimon.data.Timestamp;
24 | import org.apache.paimon.predicate.Predicate;
25 | import org.apache.paimon.predicate.PredicateBuilder;
26 | import org.apache.paimon.types.RowType;
27 |
28 | import io.airlift.slice.Slice;
29 | import io.trino.spi.predicate.Domain;
30 | import io.trino.spi.predicate.Range;
31 | import io.trino.spi.predicate.TupleDomain;
32 | import io.trino.spi.type.ArrayType;
33 | import io.trino.spi.type.BigintType;
34 | import io.trino.spi.type.BooleanType;
35 | import io.trino.spi.type.DateType;
36 | import io.trino.spi.type.DecimalType;
37 | import io.trino.spi.type.DoubleType;
38 | import io.trino.spi.type.IntegerType;
39 | import io.trino.spi.type.LongTimestampWithTimeZone;
40 | import io.trino.spi.type.MapType;
41 | import io.trino.spi.type.RealType;
42 | import io.trino.spi.type.Type;
43 | import io.trino.spi.type.VarbinaryType;
44 | import io.trino.spi.type.VarcharType;
45 |
46 | import java.math.BigDecimal;
47 | import java.util.ArrayList;
48 | import java.util.List;
49 | import java.util.Map;
50 | import java.util.Optional;
51 |
52 | import static io.trino.spi.type.TimeType.TIME_MILLIS;
53 | import static io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS;
54 | import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS;
55 | import static io.trino.spi.type.Timestamps.PICOSECONDS_PER_MILLISECOND;
56 | import static java.lang.Float.intBitsToFloat;
57 | import static java.lang.Math.toIntExact;
58 | import static java.util.Objects.requireNonNull;
59 | import static org.apache.paimon.predicate.PredicateBuilder.and;
60 | import static org.apache.paimon.predicate.PredicateBuilder.or;
61 |
62 | /** Trino filter to flink predicate. */
63 | public class TrinoFilterConverter {
64 |
65 | private final RowType rowType;
66 | private final PredicateBuilder builder;
67 |
68 | public TrinoFilterConverter(RowType rowType) {
69 | this.rowType = rowType;
70 | this.builder = new PredicateBuilder(rowType);
71 | }
72 |
73 | public Optional convert(TupleDomain tupleDomain) {
74 | if (tupleDomain.isAll()) {
75 | // TODO alwaysTrue
76 | return Optional.empty();
77 | }
78 |
79 | if (tupleDomain.getDomains().isEmpty()) {
80 | // TODO alwaysFalse
81 | return Optional.empty();
82 | }
83 |
84 | Map domainMap = tupleDomain.getDomains().get();
85 | List conjuncts = new ArrayList<>();
86 | List fieldNames = FieldNameUtils.fieldNames(rowType);
87 | for (Map.Entry entry : domainMap.entrySet()) {
88 | TrinoColumnHandle columnHandle = entry.getKey();
89 | Domain domain = entry.getValue();
90 | int index = fieldNames.indexOf(columnHandle.getColumnName());
91 | if (index != -1) {
92 | try {
93 | conjuncts.add(toPredicate(index, columnHandle.getTrinoType(), domain));
94 | } catch (UnsupportedOperationException ignored) {
95 | }
96 | }
97 | }
98 |
99 | if (conjuncts.isEmpty()) {
100 | return Optional.empty();
101 | }
102 | return Optional.of(and(conjuncts));
103 | }
104 |
105 | private Predicate toPredicate(int columnIndex, Type type, Domain domain) {
106 | if (domain.isAll()) {
107 | // TODO alwaysTrue
108 | throw new UnsupportedOperationException();
109 | }
110 | if (domain.getValues().isNone()) {
111 | if (domain.isNullAllowed()) {
112 | return builder.isNull((columnIndex));
113 | }
114 | // TODO alwaysFalse
115 | throw new UnsupportedOperationException();
116 | }
117 |
118 | if (domain.getValues().isAll()) {
119 | if (domain.isNullAllowed()) {
120 | // TODO alwaysTrue
121 | throw new UnsupportedOperationException();
122 | }
123 | return builder.isNotNull((columnIndex));
124 | }
125 |
126 | // TODO support structural types
127 | if (type instanceof ArrayType
128 | || type instanceof MapType
129 | || type instanceof io.trino.spi.type.RowType) {
130 | // Fail fast. Ignoring expression could lead to data loss in case of deletions.
131 | throw new UnsupportedOperationException();
132 | }
133 |
134 | if (type.isOrderable()) {
135 | List orderedRanges = domain.getValues().getRanges().getOrderedRanges();
136 | List