-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix lack of valid class loader for TableChangesSplitProcessor in Delta/Iceberg #19849
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
Changes from all commits
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,53 @@ | ||
| /* | ||
| * Licensed 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 io.trino.plugin.base.classloader; | ||
|
|
||
| import io.trino.spi.classloader.ThreadContextClassLoader; | ||
| import io.trino.spi.connector.ConnectorSession; | ||
| import io.trino.spi.connector.ConnectorSplit; | ||
| import io.trino.spi.function.table.ConnectorTableFunctionHandle; | ||
| import io.trino.spi.function.table.TableFunctionDataProcessor; | ||
| import io.trino.spi.function.table.TableFunctionProcessorProvider; | ||
| import io.trino.spi.function.table.TableFunctionSplitProcessor; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public final class ClassLoaderSafeTableFunctionProcessorProvider | ||
| implements TableFunctionProcessorProvider | ||
| { | ||
| private final TableFunctionProcessorProvider delegate; | ||
| private final ClassLoader classLoader; | ||
|
|
||
| public ClassLoaderSafeTableFunctionProcessorProvider(TableFunctionProcessorProvider delegate, ClassLoader classLoader) | ||
| { | ||
| this.delegate = requireNonNull(delegate, "delegate is null"); | ||
| this.classLoader = requireNonNull(classLoader, "classLoader is null"); | ||
| } | ||
|
|
||
| @Override | ||
| public TableFunctionDataProcessor getDataProcessor(ConnectorTableFunctionHandle handle) | ||
| { | ||
| try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { | ||
| return delegate.getDataProcessor(handle); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public TableFunctionSplitProcessor getSplitProcessor(ConnectorSession session, ConnectorTableFunctionHandle handle, ConnectorSplit split) | ||
| { | ||
| try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { | ||
| return delegate.getSplitProcessor(session, handle, split); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed 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 io.trino.plugin.base.classloader; | ||
|
|
||
| import io.trino.spi.classloader.ThreadContextClassLoader; | ||
| import io.trino.spi.function.table.TableFunctionProcessorState; | ||
| import io.trino.spi.function.table.TableFunctionSplitProcessor; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public final class ClassLoaderSafeTableFunctionSplitProcessor | ||
| implements TableFunctionSplitProcessor | ||
| { | ||
| private final TableFunctionSplitProcessor delegate; | ||
| private final ClassLoader classLoader; | ||
|
|
||
| public ClassLoaderSafeTableFunctionSplitProcessor(TableFunctionSplitProcessor delegate, ClassLoader classLoader) | ||
| { | ||
| this.delegate = requireNonNull(delegate, "delegate is null"); | ||
| this.classLoader = requireNonNull(classLoader, "classLoader is null"); | ||
| } | ||
|
|
||
| @Override | ||
| public TableFunctionProcessorState process() | ||
| { | ||
| try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { | ||
| return delegate.process(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| import com.google.inject.Inject; | ||
| import io.trino.filesystem.TrinoFileSystemFactory; | ||
| import io.trino.parquet.ParquetReaderOptions; | ||
| import io.trino.plugin.base.classloader.ClassLoaderSafeTableFunctionSplitProcessor; | ||
| import io.trino.plugin.deltalake.DeltaLakeConfig; | ||
| import io.trino.plugin.hive.FileFormatDataSourceStats; | ||
| import io.trino.plugin.hive.parquet.ParquetReaderConfig; | ||
|
|
@@ -54,14 +55,15 @@ public TableChangesProcessorProvider( | |
| @Override | ||
| public TableFunctionSplitProcessor getSplitProcessor(ConnectorSession session, ConnectorTableFunctionHandle handle, ConnectorSplit split) | ||
| { | ||
| return new TableChangesFunctionProcessor( | ||
| return new ClassLoaderSafeTableFunctionSplitProcessor(new TableChangesFunctionProcessor( | ||
|
Member
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. is it fixing a bug?
Member
Author
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. Added to description
Member
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. thanks!
Member
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. discussed offline; this is a bug fix please change the commit title from "Introduce ClassLoaderSafeTableFunctionSplitProcessor" to something that indicates it is a fix (perhaps "Fix ....") |
||
| session, | ||
| fileSystemFactory, | ||
| parquetDateTimeZone, | ||
| domainCompactionThreshold, | ||
| fileFormatDataSourceStats, | ||
| parquetReaderOptions, | ||
| (TableChangesTableFunctionHandle) handle, | ||
| (TableChangesSplit) split); | ||
| (TableChangesSplit) split), | ||
| getClass().getClassLoader()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Licensed 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 io.trino.plugin.hive; | ||
|
|
||
| import io.trino.spi.function.FunctionProvider; | ||
|
|
||
| public class NoopFunctionProvider | ||
| implements FunctionProvider | ||
| {} |
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.
update
TestClassLoaderSafeWrappers