Skip to content

Commit 0b37230

Browse files
can now supply a custom cql in the cdm.yaml
1 parent f791bc5 commit 0b37230

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

cdm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ tables:
55
- maptest
66
- users2
77
version: 2.2
8+
schema: schema.cql

src/main/java/com/datastax/cdm/CDMArgs.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ public class CDMArgs {
2222
@Parameter(names = {"--no-data", "--nodata"}, description = "Only set up schema")
2323
public Boolean noData = false; // setting this is schema only
2424

25+
@Parameter(names = "--help", help = true)
26+
private boolean help;
27+
28+
2529
}

src/main/java/com/datastax/cdm/CassandraDatasetManager.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class InvalidArgsException extends Exception {
4242
private String cassandraContactPoint;
4343
private String host;
4444
private CDMArgs args;
45+
public String relative_schema_path = "schema.cql";
4546

4647

4748
CassandraDatasetManager() {
@@ -64,7 +65,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
6465

6566
System.out.println("Starting CDM");
6667
CDMArgs parsedArgs = new CDMArgs();
67-
new JCommander(parsedArgs, args);
68+
JCommander jc = new JCommander(parsedArgs, args);
6869

6970

7071
// check for the .cdm directory
@@ -97,6 +98,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
9798
// load schema using cqlsh - should this use a normal CSV loader eventually?
9899
if(args.length == 0) {
99100
cdm.printHelp();
101+
jc.usage();
100102
return;
101103
}
102104

@@ -118,7 +120,8 @@ public static void main(String[] args) throws IOException, InterruptedException,
118120
cdm.update();
119121
break;
120122
default:
121-
System.out.println("Not sure what to do.");
123+
jc.usage();
124+
cdm.printHelp();
122125

123126
}
124127
System.out.println("Finished.");
@@ -221,7 +224,6 @@ void install(String name) throws IOException, InterruptedException, GitAPIExcept
221224
// all the paths
222225
dataPath = path + "/data/";
223226
configLocation = path + "/cdm.yaml";
224-
schema = path + "/schema.cql";
225227

226228
File configFile = new File(configLocation);
227229

@@ -230,6 +232,15 @@ void install(String name) throws IOException, InterruptedException, GitAPIExcept
230232
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
231233

232234
Config config = mapper.readValue(configFile, Config.class);
235+
236+
if(config.schema != null) {
237+
schema = path + "/" + config.schema;
238+
239+
}
240+
else {
241+
schema = path + "/schema.cql";
242+
}
243+
System.out.println("Loading schema from " + schema);
233244
String address = this.host;
234245

235246
Cluster cluster = Cluster.builder().addContactPoint(address).build();

src/main/java/com/datastax/cdm/Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public class Config {
99
public String keyspace;
1010
public List<String> tables;
1111
public String version;
12+
public String schema;
1213
}

0 commit comments

Comments
 (0)