|
| 1 | +package troy.cql3_3.lexical |
| 2 | + |
| 3 | +import org.scalatest._ |
| 4 | +import troy.cql.ast.DataType |
| 5 | +import troy.schema.SchemaTestUtils._ |
| 6 | + |
| 7 | +class DataManipulationSchemaSpec extends FlatSpec with Matchers { |
| 8 | + implicit lazy val schema = buildSchema( |
| 9 | + """ |
| 10 | + | CREATE KEYSPACE specs WITH replication = {'class': 'SimpleStrategy' , 'replication_factor': '1'}; |
| 11 | + | CREATE TABLE specs.test ( |
| 12 | + | foo int PRIMARY KEY, |
| 13 | + | bar TEXT, |
| 14 | + | barfoo TEXT |
| 15 | + | ); |
| 16 | + """.stripMargin |
| 17 | + ) |
| 18 | + |
| 19 | + // TODO: https://github.com/cassandra-scala/troy/issues/136 |
| 20 | + "Schema" should "support select *" ignore { |
| 21 | + asteriskOf("SELECT * FROM specs.test;").size shouldBe 3 |
| 22 | + } |
| 23 | + |
| 24 | + it should "support select with DISTINCT partition" in { |
| 25 | + columnsOf("SELECT DISTINCT foo FROM specs.test;").head shouldBe DataType.Int |
| 26 | + } |
| 27 | + |
| 28 | + it should "support select with JSON formate" in { |
| 29 | + columnsOf("SELECT JSON foo FROM specs.test;").head shouldBe DataType.Int |
| 30 | + } |
| 31 | + |
| 32 | + // TODO: https://github.com/cassandra-scala/troy/issues/134 |
| 33 | + it should "support select with count aggregate function" ignore { |
| 34 | + columnsOf("SELECT count(foo) FROM specs.test;").head shouldBe DataType.Int |
| 35 | + } |
| 36 | + |
| 37 | + it should "support select with min aggregate function" ignore { |
| 38 | + columnsOf("SELECT min(foo) FROM specs.test;").head shouldBe DataType.Int |
| 39 | + } |
| 40 | + |
| 41 | + it should "support select with max aggregate function" ignore { |
| 42 | + columnsOf("SELECT max(foo) FROM specs.test;").head shouldBe DataType.Int |
| 43 | + } |
| 44 | + |
| 45 | + it should "support select with sum aggregate function" ignore { |
| 46 | + columnsOf("SELECT sum(foo) FROM specs.test;").head shouldBe DataType.Int |
| 47 | + } |
| 48 | + |
| 49 | + it should "support select with avg aggregate function" ignore { |
| 50 | + columnsOf("SELECT avg(foo) FROM specs.test;").head shouldBe DataType.Int |
| 51 | + } |
| 52 | + |
| 53 | + // TODO: https://github.com/cassandra-scala/troy/issues/137 |
| 54 | + it should "support select with User-defined aggregate function" ignore { |
| 55 | + columnsOf("SELECT UDAggregate(foo) FROM specs.test;").head shouldBe DataType.Int |
| 56 | + } |
| 57 | +} |
0 commit comments