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

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

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

    https://github.com/apache/nifi/pull/1464#discussion_r99665513
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java
 ---
    @@ -420,7 +433,11 @@ private String generateInsert(final JsonNode rootNode, 
final Map<String, String>
     
             final StringBuilder sqlBuilder = new StringBuilder();
             int fieldCount = 0;
    -        sqlBuilder.append("INSERT INTO ").append(tableName).append(" (");
    +        sqlBuilder.append("INSERT INTO ");
    +        if (quoteTableName) 
sqlBuilder.append(schema.getQuotedIdentifierString());
    --- End diff --
    
    Quick remark: could you change to do it similarly to column names? 
Something like:
    ````java
                if(quoteTableName){
                    sqlBuilder.append(schema.getQuotedIdentifierString())
                            .append(tableName)
                            .append(schema.getQuotedIdentifierString());
                } else {
                    sqlBuilder.append(tableName);
                }
    ````
    This way you avoid two if evaluations.
    
    Also, since you are going to make a change, could you update this same 
piece of code for column names to avoid the negation check in the if statement? 
To have:
    ````java
                if(escapeColumnNames){
                    sqlBuilder.append(schema.getQuotedIdentifierString())
                            .append(normalizedColName)
                            .append(schema.getQuotedIdentifierString());
                } else {
                    sqlBuilder.append(normalizedColName);
                }
    ````
    I believe this is more efficient.
    
    Otherwise, LGTM.


> ConvertJSONToSQL Does not work with table identifiers that need to be quoted
> ----------------------------------------------------------------------------
>
>                 Key: NIFI-3429
>                 URL: https://issues.apache.org/jira/browse/NIFI-3429
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.2.0
>            Reporter: Nicholas Carenza
>            Priority: Minor
>             Fix For: 1.2.0
>
>
> I have a table identifer that needs to be quoted. If i supple the table 
> identifer unquoted in the properties, the processor can convert the json to 
> sql but the output sql doesn't have the table name quoted even if I select 
> the option Quote Identifiers because, true to the description, it only 
> applies to column identifiers. If I supply the table identifier quoted in the 
> properties, then the processor fails completely because it can't find the 
> table.



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

Reply via email to