我通过materiliazed视图使用Java存储数据到Cassandra但是我遇到了问题。问题是它不会将数据保存到Cassandra数据库。我收到了这个错误。
No columns are defined for Materialized View other than primary key
REATE MATERIALIZED VIEW IF NOT iSISTS sensorkeyspace.maxtable AS select sensor_id,来自sensorkeyspace.sensortable的湿度(湿度不为空)PRIMARY KEY(sensor_id) 线程" main"中的例外情况com.datastax.driver.core.exceptions.InvalidQueryException:没有为主键以外的物化视图定义列 at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50) 在com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37) at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) 在com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:64) 在com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39) 在sparkproject.SparkApp.main(SparkApp.java:41) 引起:com.datastax.driver.core.exceptions.InvalidQueryException:没有为主键以外的物化视图定义列 at com.datastax.driver.core.Responses $ Error.asException(Responses.java:136) at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179) 在com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:174) 在com.datastax.driver.core.RequestHandler.access $ 2600(RequestHandler.java:43) at com.datastax.driver.core.RequestHandler $ SpeculativeExecution.setFinalResult(RequestHandler.java:793) at com.datastax.driver.core.RequestHandler $ SpeculativeExecution.onSet(RequestHandler.java:627) at com.datastax.driver.core.Connection $ Dispatcher.channelRead0(Connection.java:1012) 在com.datastax.driver.core.Connection $ Dispatcher.channelRead0(Connection.java:935) 在io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) 在io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
答案 0 :(得分:2)
看起来您正在使用与主表相同的主键创建物化视图。请检查MV定义