Apache Phoenix:UPSERT中的值必须计算为常量。(Apache Phoenix: Values in UPSERT must evaluate to a constant. java.sql.SQLException: ERROR 204 (22008))
我想在hbase中更新一个名为EMPLOYEE的表,它看起来如下,行键是ID。
ID,Name,Age
"1","John","34"
"2","David","22"
我想在此表中添加另一个名为City的列。 使用Apache phoenix我首先执行此命令以更改现有模式。
ALTER TABLE "EMPLOYEE" ADD IF NOT EXISTS "CITY" VARCHAR(40)
该命令执行成功。 然后我尝试插入值。 使用以下命令。
UPSERT INTO "EMPLOYEE" ("ID","CITY") VALUES ("1", "London")
但是,每次执行此操作时,都会出现以下错误 -
Exception in thread "main" java.sql.SQLException: ERROR 204 (22008): Values in UPSERT must evaluate to a constant.
我在这里缺少的是什么,导致错误。
I want to update a table named EMPLOYEE in hbase, which looks like the following and the row key is ID.
ID,Name,Age
"1","John","34"
"2","David","22"
I want to add another column named City in this table. Using Apache phoenix I executed this command first to alter the existing schema.
ALTER TABLE "EMPLOYEE" ADD IF NOT EXISTS "CITY" VARCHAR(40)
This command executed successfully. Then I tried to insert values. Using the following command.
UPSERT INTO "EMPLOYEE" ("ID","CITY") VALUES ("1", "London")
However every time I execute this, I get the following error -
Exception in thread "main" java.sql.SQLException: ERROR 204 (22008): Values in UPSERT must evaluate to a constant.
What is it what I am missing here, that is causing the error.
原文:https://stackoverflow.com/questions/37367634
更新时间:2020-02-05 15:29
最满意答案
字符串文字值应该是单引号, ' 。
I figured out what was causing the error, Changing double quotes to single quotes worked for me -
UPSERT INTO "EMPLOYEE" ("ID","CITY") VALUES ('1', 'London')
2016-05-22
相关问答
Operation not allowed after ResultSet closed,结果集关闭导致的导致的报错 通常一个数据库连接只能同时处理一个数据集,如果在轮询结果集时,又用这个数据库连接进行增删改查的操作,都会导致结果集关闭,可以尝试使用另一个数据库连接来进行增删改查操作
检查$HBASE_HOME/lib和$HBASE_HOME/conf/hbase-site.xml 。 当你启动phoenix时,它将创建4个系统表: SYSTEM.CATALOG
SYSTEM.FUNCTION
SYSTEM.SEQUENCE
SYSTEM.STATS
表SYSTEM.CATALOG和SYSTEM.FUNCTION声明使用协处理器org.apache.phoenix.coprocessor.MetaDataEndpointImpl ,但似乎你的HMaster无法加载它。 Che
...
你正在调用result.next()两次。 我假设你的查询只返回1行,因为你试图通过Userid进行匹配。 当调用第二个result.next()时, ResultSet不会返回行。 这就是SQLException原因。 除去第一个result.next()像这样: result = st.executeQuery();
if(!result.next()){
input = result.getAsciiStream(1);
}
You are calling result.n
...
字符串文字值应该是单引号, ' 。 I figured out what was causing the error, Changing double quotes to single quotes worked for me - UPSERT INTO "EMPLOYEE" ("ID","CITY") VALUES ('1', 'London')
我的情况我通过在pom.xml中使用下面的依赖来解决这个问题
org.apache.hbase
hbase-protocol
1.1.11
只是为了更新你我有Hbase版本:1.1和凤凰是4.7 I my case I solved this by
...
public ClienteCRUD(String nome, String cpf, String endereco, String cidade, String uf, String cep) throws SQLException {
String[] str = {nome, cpf, endereco, cidade, uf, cep};
String url = "jdbc:mysql://localhost/vendas";
...
在你的问题中完全遵循你想要做的事情有点难,但我认为我得到了它的主要要点。 基本上,您希望lockTheMachine()函数upsert只设置nameMachine , isUsed和whoUseIt字段,并且您只需要upsertCollectionMachines()来设置stateMachine , ipAddr , port , protocol字段,并且只设置isUsed和whoUseIt为默认值on插? 你应该可以使用下面的upserts来做到这一点。 在upsertCollection
...
什么是永远不会有效的是当前的方法是将表的名称和列的名称设置为以下代码段中的PreparedStatement: String SQLStatement = null;
...
SQLStatement = "SELECT count(*) FROM ? WHERE ? = ?";
ps = conn.prepareStatement(SQLStatement);
ps.setString(1, DBtablename);
ps.setString(2, DBStatus);
...
我过去遇到过这个问题。 基本上你需要从表中选择一些行来让UDF工作(前提是你已经正确编写了其余的UDF) 所以像 select udffunc(1,1)将无效 但 从表中选择udffunc(col1,1) http://eyang3.github.io/2016/12/13/post/ I had this problem in the past. Basically you need to select some row from a table for UDF's to work (provi
...