@@ -4,6 +4,8 @@ import com.datastax.spark.connector.SparkCassandraITWordSpecBase
4
4
import com .datastax .spark .connector .cluster .DefaultCluster
5
5
import com .datastax .spark .connector .types ._
6
6
import com .datastax .spark .connector .util .schemaFromCassandra
7
+ import org .apache .spark .sql .cassandra ._
8
+ import org .apache .spark .sql .functions .col
7
9
import org .scalatest .Inspectors ._
8
10
9
11
class SchemaSpec extends SparkCassandraITWordSpecBase with DefaultCluster {
@@ -31,7 +33,7 @@ class SchemaSpec extends SparkCassandraITWordSpecBase with DefaultCluster {
31
33
| d7_int int,
32
34
| d8_list list<int>,
33
35
| d9_map map<int, varchar>,
34
- | d10_set set<int>,
36
+ | d10_set frozen< set<int> >,
35
37
| d11_timestamp timestamp,
36
38
| d12_uuid uuid,
37
39
| d13_timeuuid timeuuid,
@@ -43,8 +45,15 @@ class SchemaSpec extends SparkCassandraITWordSpecBase with DefaultCluster {
43
45
""" .stripMargin)
44
46
session.execute(
45
47
s """ CREATE INDEX test_d9_map_idx ON $ks.test (keys(d9_map)) """ )
48
+ session.execute(
49
+ s """ CREATE INDEX test_d9_m23423ap_idx ON $ks.test (full(d10_set)) """ )
46
50
session.execute(
47
51
s """ CREATE INDEX test_d7_int_idx ON $ks.test (d7_int) """ )
52
+
53
+ for (i <- 0 to 9 ) {
54
+ session.execute(s " insert into $ks.test (k1,k2,k3,c1,c2,c3,d10_set) " +
55
+ s " values ( $i, 'text $i', $i, $i, 'text $i', 123e4567-e89b-12d3-a456-42661417400 $i, { $i, ${i* 10 }}) " )
56
+ }
48
57
}
49
58
50
59
val schema = schemaFromCassandra(conn)
@@ -120,7 +129,7 @@ class SchemaSpec extends SparkCassandraITWordSpecBase with DefaultCluster {
120
129
table.columnByName(" d7_int" ).columnType shouldBe IntType
121
130
table.columnByName(" d8_list" ).columnType shouldBe ListType (IntType )
122
131
table.columnByName(" d9_map" ).columnType shouldBe MapType (IntType , VarCharType )
123
- table.columnByName(" d10_set" ).columnType shouldBe SetType (IntType )
132
+ table.columnByName(" d10_set" ).columnType shouldBe SetType (IntType , true )
124
133
table.columnByName(" d11_timestamp" ).columnType shouldBe TimestampType
125
134
table.columnByName(" d12_uuid" ).columnType shouldBe UUIDType
126
135
table.columnByName(" d13_timeuuid" ).columnType shouldBe TimeUUIDType
@@ -135,13 +144,19 @@ class SchemaSpec extends SparkCassandraITWordSpecBase with DefaultCluster {
135
144
udt.columnTypes shouldBe Seq (VarCharType , VarCharType , IntType )
136
145
}
137
146
138
- " should not recognize column with collection index as indexed" in {
139
- table.indexedColumns.size shouldBe 1
140
- table.indexedColumns.head.columnName shouldBe " d7_int"
147
+ " should recognize column with collection index as indexed" in {
148
+ table.indexedColumns.size shouldBe 3
149
+ table.indexedColumns.map(_.columnName).toSet shouldBe Set (" d7_int" , " d9_map" , " d10_set" )
150
+ }
151
+
152
+ " allow for pushdown on frozen indexed collection" in {
153
+ val value1 = spark.read.cassandraFormat(table.tableName, ks).load().where(col(" d10_set" ).equalTo(Array (3 , 30 )))
154
+ value1.explain()
155
+ value1.collect().size shouldBe 1
141
156
}
142
157
143
158
" should hold all indices retrieved from cassandra" in {
144
- table.indexes.size shouldBe 2
159
+ table.indexes.size shouldBe 3
145
160
}
146
161
}
147
162
0 commit comments