Skip to content

Commit

Permalink
Enable SQL based row limits for trino (dbeaver#34888)
Browse files Browse the repository at this point in the history
* When trino is configured with fault tolerant execution, queries
  are run to completion before results are returned
* This means previewing a table in dbeaver ends up scanning the whole
  table and taking up potentially a huge amount of resources
* Trino supports SQL limit statement, so enable SQL based row limiting
  in the plugin and make it the default

Co-authored-by: Josh Baxter <[email protected]>
Co-authored-by: Diana <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 2f55793 commit d8f5f97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/org.jkiss.dbeaver.ext.generic/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@
supportedConfigurationTypes="MANUAL,URL"
webURL="https://trino.io/"
categories="sql,bigdata,hadoop">
<property name="@dbeaver-default-resultset.maxrows.sql" value="true"/>
<file type="jar" path="maven:/io.trino:trino-jdbc:RELEASE" bundle="!drivers.trino"/>
<file type="license" path="https://www.apache.org/licenses/LICENSE-2.0.txt" bundle="!drivers.trino"/>
<file type="jar" path="drivers/trino" bundle="drivers.trino"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
package org.jkiss.dbeaver.ext.trino.model;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.generic.model.GenericDataSource;
import org.jkiss.dbeaver.ext.generic.model.GenericSQLDialect;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.exec.DBCQueryTransformer;
import org.jkiss.dbeaver.model.exec.DBCQueryTransformType;
import org.jkiss.dbeaver.model.impl.sql.QueryTransformerLimit;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.utils.CommonUtils;

Expand Down Expand Up @@ -52,4 +56,13 @@ public ErrorType discoverErrorType(@NotNull Throwable error) {
}
return super.discoverErrorType(error);
}

@Nullable
@Override
public DBCQueryTransformer createQueryTransformer(@NotNull DBCQueryTransformType type) {
if (type == DBCQueryTransformType.RESULT_SET_LIMIT) {
return new QueryTransformerLimit(false, false);
}
return null;
}
}

0 comments on commit d8f5f97

Please sign in to comment.