Skip to content

Commit

Permalink
Handle PersistentDataset
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Jan 24, 2024
1 parent e1c7ae0 commit 2eeefe1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/fr/insee/trevas/jupyter/VtlKernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fr.insee.vtl.engine.VtlScriptEngine;
import fr.insee.vtl.model.Dataset;
import fr.insee.vtl.model.PersistentDataset;
import fr.insee.vtl.model.Structured;
import fr.insee.vtl.spark.SparkDataset;
import io.github.spencerpark.jupyter.channels.JupyterConnection;
Expand Down Expand Up @@ -58,9 +59,16 @@ private static Map<String, Dataset.Role> getRoleMap(fr.insee.vtl.model.Dataset d
private static SparkDataset asSparkDataset(Dataset dataset) {
if (dataset instanceof SparkDataset) {
return (SparkDataset) dataset;
} else {
return new SparkDataset(dataset, getRoleMap(dataset), spark);
}
if (dataset instanceof PersistentDataset) {
fr.insee.vtl.model.Dataset ds = ((PersistentDataset) dataset).getDelegate();
if (ds instanceof SparkDataset) {
return (SparkDataset) ds;
} else {
return new SparkDataset(ds, getRoleMap(dataset), spark);
}
}
throw new IllegalArgumentException("Unknow dataset type");
}

public static SparkDataset loadParquet(String path) throws Exception {
Expand Down

0 comments on commit 2eeefe1

Please sign in to comment.