Skip to content

Commit

Permalink
If there is a single input, name the catchall group (and thus the out…
Browse files Browse the repository at this point in the history
…put(s)) after it.
  • Loading branch information
OndraZizka committed Nov 19, 2018
1 parent a341eb6 commit 666e4e0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cz/dynawest/csvcruncher/Cruncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class Cruncher
public static final Pattern REGEX_SQL_COLUMN_VALID_NAME = Pattern.compile("[a-z][a-z0-9_]*", Pattern.CASE_INSENSITIVE);

public static final String SQL_TABLE_PLACEHOLDER = "$table";
private static final String DEFAULT_SQL = "SELECT "+ SQL_TABLE_PLACEHOLDER + " FROM " + SQL_TABLE_PLACEHOLDER;
static final String DEFAULT_SQL = "SELECT "+ SQL_TABLE_PLACEHOLDER + " FROM " + SQL_TABLE_PLACEHOLDER;

private Connection jdbcConn;
private HsqlDbHelper dbHelper;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/cz/dynawest/csvcruncher/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import java.util.regex.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Setter
@Getter
@Slf4j
public final class Options
{
protected List<String> inputPaths = new ArrayList<>();
Expand Down Expand Up @@ -47,12 +49,10 @@ public void validate() throws FileNotFoundException
throw new IllegalArgumentException(" -in is not set.");

// SQL may be omitted if there is a request to combine files or convert to JSON. Otherwise it would be a no-op.
if (this.sql == null && (
!Options.CombineInputFiles.NONE.equals(this.combineInputFiles)
||
!Options.JsonExportFormat.NONE.equals(this.jsonExportFormat)
))
throw new IllegalArgumentException(" -sql is not set.");
if (this.sql == null) {
log.debug(" -sql is not set, using default: " + Cruncher.DEFAULT_SQL);
this.sql = Cruncher.DEFAULT_SQL;
}

if (this.outputPathCsv == null)
throw new IllegalArgumentException(" -out is not set.");
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/cz/dynawest/csvcruncher/util/FilesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,16 @@ public static Map<Path, List<Path>> expandFilterSortInputFilesGroups(List<Path>
log.info(" *** No files found.");
return Collections.emptyMap();
}
if (paths.size() == 1)

if (paths.size() == 1) {
return mapOfIdentityToSingletonList(paths);
}

// If there is only one input path, use it as the originating path. Maybe it should be done in combine()?
if (inputPaths.size() == 1) {
fileGroupsToCombine.remove(null);
fileGroupsToCombine.put(inputPaths.get(0), paths);
}
}

fileGroupsToCombine = sortFileGroups(options, fileGroupsToCombine);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<target>System.err</target>
<!-- Encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default. -->
<encoder>
<pattern>%d{HH:mm:ss} %-5level %logger{35}: %msg%n</pattern>
<pattern>%d{HH:mm:ss} %.-2level %logger{0}: %msg%n</pattern><!-- %-5level -->
</encoder>
</appender>

Expand Down

0 comments on commit 666e4e0

Please sign in to comment.