https://kotlinlang.org logo
l

Luis Munoz

04/15/2020, 6:38 PM
I'm thinking about using exposed with MemSQL which supports mariadb driver. I cannot figure out how to create a table because it needs these SHARD statement, how do I add that?
Copy code
sqlQueryBuilder.append("id BIGINT AUTO_INCREMENT NOT NULL,");
sqlQueryBuilder.append("ts DATETIME(6) NOT NULL,");
sqlQueryBuilder.append("uuid VARBINARY(32) NOT NULL,");
sqlQueryBuilder.append("data JSON,");
sqlQueryBuilder.append("SHARD(id),");
sqlQueryBuilder.append("KEY(ts) USING CLUSTERED COLUMNSTORE)");
is it possible to get the same statement with exposed?
t

tapac

04/15/2020, 8:03 PM
It's unsupported yet, but you could "hack" deafult create by implementing your own table type. Something like:
Copy code
abstract class ShardedTable(tableName: String, val shard: String) : Table(tableName) {

    override fun createStatement(): List<String> {
        return super.createStatement().map { statement ->
            if (statement.startsWith("CREATE TABLE "))
                statement.removeSuffix(")") + "SHARD($shard))"
            else statement
        }
    }
}
It's the example, tune it with the right syntax.
l

Luis Munoz

04/15/2020, 10:29 PM
thank you