@@ -15,7 +15,8 @@ private final case class Config(
15
15
propertySet : PropertySet = PropertySets .AllProperties ,
16
16
addDefinitions : Boolean = false ,
17
17
detectDynamic : Boolean = false ,
18
- detectDisjoint : Boolean = false
18
+ detectDisjoint : Boolean = false ,
19
+ treeReduce : Boolean = false
19
20
)
20
21
21
22
object JsonoidSpark {
@@ -60,6 +61,10 @@ object JsonoidSpark {
60
61
opt[Unit ]('j' , " detect-disjoint" )
61
62
.action((x, c) => c.copy(detectDisjoint = true ))
62
63
.text(" detect objects with disjoint keys" )
64
+
65
+ opt[Unit ]('t' , " tree-reduce" )
66
+ .action((x, c) => c.copy(treeReduce = true ))
67
+ .text(" use treeReduce for schema reduction" )
63
68
}
64
69
65
70
parser.parse(args, Config ()) match {
@@ -71,8 +76,11 @@ object JsonoidSpark {
71
76
val jsonRdd = JsonoidRDD .fromStringRDD(
72
77
sc.textFile(config.input)
73
78
)(p)
74
- var schema : ObjectSchema =
79
+ var schema : ObjectSchema = if (config.treeReduce) {
80
+ jsonRdd.treeReduceSchemas().asInstanceOf [ObjectSchema ]
81
+ } else {
75
82
jsonRdd.reduceSchemas().asInstanceOf [ObjectSchema ]
83
+ }
76
84
77
85
// Skip transformation if we know the required properties don't exist
78
86
if (! (config.propertySet === PropertySets .MinProperties )) {
0 commit comments