kaspersorensen commented on a change in pull request #208: the result of column.getNativeType() may be null and add pagination function to the Hive sql. URL: https://github.com/apache/metamodel/pull/208#discussion_r259643323
########## File path: jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/RowNumberQueryRewriter.java ########## @@ -0,0 +1,68 @@ +/** + * 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. + */ +package org.apache.metamodel.jdbc.dialects; + +import java.util.List; +import org.apache.metamodel.jdbc.JdbcDataContext; +import org.apache.metamodel.query.FromItem; +import org.apache.metamodel.query.Query; +import org.apache.metamodel.query.SelectItem; + +/** + * Query rewriter for databases that support RowNumber keywords for max + * rows and first row properties. + **/ + +public class RowNumberQueryRewriter extends DefaultQueryRewriter { + + public RowNumberQueryRewriter(JdbcDataContext dataContext) { + super(dataContext); + } + + protected String getRowNumberSql(Query query, Integer maxRows, Integer firstRow) { + final Query innerQuery = query.clone(); + innerQuery.setFirstRow(null); + innerQuery.setMaxRows(null); + + final Query outerQuery = new Query(); + final FromItem subQuerySelectItem = new FromItem(innerQuery).setAlias("metamodel_subquery"); + outerQuery.from(subQuerySelectItem); + + final List<SelectItem> innerSelectItems = innerQuery.getSelectClause().getItems(); + for (SelectItem selectItem : innerSelectItems) { + outerQuery.select(new SelectItem(selectItem, subQuerySelectItem)); + } + Review comment: No need for the double line breaks ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services