You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/03/10 07:36:04 UTC

[jira] [Commented] (NIFI-3481) DB Adapter for MS SQL 2012+

    [ https://issues.apache.org/jira/browse/NIFI-3481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15904624#comment-15904624 ] 

ASF GitHub Bot commented on NIFI-3481:
--------------------------------------

Github user SQLGuyChuck commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1510#discussion_r105343654
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/db/impl/MSSQLDatabaseAdapter.java ---
    @@ -0,0 +1,82 @@
    +/*
    + * 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.nifi.processors.standard.db.impl;
    +
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.nifi.processors.standard.db.DatabaseAdapter;
    +
    +/**
    + * A database adapter that generates MS SQL Compatible SQL.
    + */
    +public class MSSQLDatabaseAdapter implements DatabaseAdapter {
    +    @Override
    +    public String getName() {
    +        return "MS SQL";
    +    }
    +
    +    @Override
    +    public String getDescription() {
    +        return "Generates MS SQL Compatible SQL, for version 2012 or greater";
    +    }
    +
    +    @Override
    +    public String getSelectStatement(String tableName, String columnNames, String whereClause, String orderByClause, Long limit, Long offset) {
    +        if (StringUtils.isEmpty(tableName)) {
    +            throw new IllegalArgumentException("Table name cannot be null or empty");
    +        }
    +        final StringBuilder query = new StringBuilder("SELECT ");
    +
    +        //If this is a limit query and not a paging query then use TOP in MS SQL
    +        if (limit != null && offset == null){
    +            query.append("TOP ");
    --- End diff --
    
    I missed the idea of pagination, so with ties would only be appropriate without it. Definitely a big undertaking to consider it.


> DB Adapter for MS SQL 2012+
> ---------------------------
>
>                 Key: NIFI-3481
>                 URL: https://issues.apache.org/jira/browse/NIFI-3481
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework
>    Affects Versions: 1.2.0
>            Reporter: Peter Wicks
>            Assignee: Peter Wicks
>            Priority: Minor
>
> Adding a new DB Adapter for MS SQL.  MS SQL does paging of queries differently then other RDBMS', including a lack of "LIMIT".
> This adds functionality for TOP and OFFSET/FETCH for paging of results with the GenerateTableFetch. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)