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

    https://github.com/apache/nifi/pull/420#discussion_r62822639
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFilterCSVColumns.java
 ---
    @@ -0,0 +1,117 @@
    +/*
    + * 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;
    +
    +import static org.junit.Assert.assertEquals;
    +
    +import java.io.FileInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.nio.file.Path;
    +import java.nio.file.Paths;
    +import java.sql.ResultSet;
    +import java.sql.SQLException;
    +import java.util.List;
    +
    +import org.apache.nifi.reporting.InitializationException;
    +import org.apache.nifi.util.MockFlowFile;
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.junit.Test;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class TestFilterCSVColumns {
    +
    +    private static final Logger LOGGER;
    +
    +    static {
    +        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", 
"info");
    +        System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
    +        System.setProperty("org.slf4j.simpleLogger.log.nifi.io.nio", 
"debug");
    +        
System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.FilterCSVColumns",
 "debug");
    +        
System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestFilterCSVColumns",
 "debug");
    +        LOGGER = LoggerFactory.getLogger(TestFilterCSVColumns.class);
    +    }
    +
    +    @Test
    +    public void testTransformSimple() throws InitializationException, 
IOException, SQLException {
    +        String sql = "select first_name, last_name, company_name, address, 
city from CSV.A where city='New York'";
    +
    +        Path inpath = 
Paths.get("src/test/resources/TestFilterCSVColumns/US500.csv");
    +        InputStream in = new FileInputStream(inpath.toFile());
    +
    +        ResultSet resultSet = FilterCSVColumns.transform(in, sql);
    +
    +        int nrofColumns = resultSet.getMetaData().getColumnCount();
    +
    +        for (int i = 1; i <= nrofColumns; i++) {
    +            System.out.print(resultSet.getMetaData().getColumnLabel(i) + " 
     ");
    +        }
    +        System.out.println();
    +
    +        while (resultSet.next()) {
    +            for (int i = 1; i <= nrofColumns; i++) {
    +                System.out.print(resultSet.getString(i)+ "  ");
    +            }
    +            System.out.println();
    +        }
    +    }
    +
    +    @Test
    +    public void testTransformCalc() throws InitializationException, 
IOException, SQLException {
    +        String sql = "select ID, AMOUNT1+AMOUNT2+AMOUNT3 as TOTAL from 
CSV.A where ID=100";
    --- End diff --
    
    Yes, reading from File and InputStream and be unified.
    But current Calcite CSV adapter supports strictly only File. 
    
    Also CSV adapter supports many ‘tables’. So SQL select supports also 
joins.
    Each ‘table’ is separate File. CSV adapter is capable of discover 
‘tables’ using files.
    CSV will scan all files in data directory.
    Using InputStream requires some kind of solutions for multiple tables.
    
    Some day we might have Calcite CSV adapter which is capable of using both 
Files and InputStreams. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to