Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gortools/src/main/scala/gorsat/process/GorPrePipe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object GorPrePipe {
val availNorCommands: Array[String] = GorPipeCommands.getNorCommands ++ GorInputSources.getInputSources

private val supportedGorSQLFileEndings = Array[String](".json",".csv",".tsv",".gor",".gorz",".gor.gz",".gord",".txt",".vcf",".bgen",".parquet",".adam",".mt",".xml")
private val commandsContainingInputSources = Array[String]("PARALLEL", "GOR","NOR","SPARK","MAP","MULTIMAP","INSET","MERGE","JOIN","LEFTJOIN","VARJOIN","GORIF", "NORIF", "EXEC"/*,"CSVSEL","CSVCC","GTGEN"*/)
private val commandsContainingInputSources = Array[String]("PARALLEL", "GOR","NOR","SPARK","MAP","MULTIMAP","INSET","MERGE","JOIN","LEFTJOIN","VARJOIN","GORIF", "NORIF", "META", "EXEC"/*,"CSVSEL","CSVCC","GTGEN"*/)
val gorpred = (p: String) => supportedGorSQLFileEndings.map(e => p.toLowerCase.endsWith(e)).reduce((a,b) => a || b)

private def getCommandArgument(command: String) : Option[CommandArguments] = {
Expand Down
34 changes: 34 additions & 0 deletions gortools/src/test/java/gorsat/Script/UTestSignature.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;

public class UTestSignature {

Expand All @@ -31,6 +32,17 @@ public void setUp() {
GorInputSources.register();
}

private String extractSingleValue(String output) {
var lines = Arrays.stream(output.split("\n"))
.map(String::trim)
.filter(line -> !line.isEmpty())
.toArray(String[]::new);

Assert.assertEquals("Expected a header row and one data row", 2, lines.length);
var values = lines[1].split("\t");
return values[values.length - 1];
}

@Test
public void testQuerySignatureAfterUpdate() throws IOException, InterruptedException {
var cachePath = workPath.resolve("cache");
Expand All @@ -50,6 +62,28 @@ public void testQuerySignatureAfterUpdate() throws IOException, InterruptedExcep
Assert.assertEquals(3, res.length);
}

@Test
public void testQuerySignatureAfterUpdateWithMetaVirtualRelation() throws IOException {
var cachePath = workPath.resolve("cache");
Files.createDirectory(cachePath);

var dataPath = workPath.resolve("data_meta.gor");
Files.writeString(dataPath, "#Chrom\tPos\nchr1\t1\n");

var query = "create meta_size = meta " + dataPath
+ " | where source='FILE' and name='SIZE' | rename value file_size | select file_size; nor [meta_size]";

var before = extractSingleValue(TestUtils.runGorPipe(query, workPath.toString(), cachePath.toString(), false, "", null));
Assert.assertEquals(String.valueOf(Files.size(dataPath)), before);

Files.writeString(dataPath, "chr1\t2\n", StandardOpenOption.APPEND);

var after = extractSingleValue(TestUtils.runGorPipe(query, workPath.toString(), cachePath.toString(), false, "", null));
Assert.assertEquals("META virtual relation should be invalidated when the source file size changes",
String.valueOf(Files.size(dataPath)), after);
Assert.assertNotEquals("META virtual relation should not reuse stale cached results", before, after);
}

@Test
public void testQuerySignatureAfterUpdateWithLink() throws IOException, InterruptedException {
var cachePath = workPath.resolve("cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ class UTestGorPrePipe extends AnyFunSuite with BeforeAndAfterAll {
assert(result.head == "../tests/data/gor/dbsnp_test.gorz")
}

test("Get used file from meta query") {
val query = "meta ../tests/data/gor/dbsnp_test.gorz | where source='FILE' and name='SIZE'"
val result = process.GorPrePipe.getUsedFiles(query, session)

assert(result.length == 1)
assert(result.head == "../tests/data/gor/dbsnp_test.gorz")
}

test("Get used file from gor query with join") {
val query = "nor ../tests/data/gor/dbsnp_test.gorz | join -snpsnp multicolumns.gor"
val result = process.GorPrePipe.getUsedFiles(query, session)
Expand Down
Loading