lirui-apache commented on code in PR #5129:
URL: https://github.com/apache/hive/pull/5129#discussion_r1537519107
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -624,6 +624,40 @@ public boolean openTransaction(String isolationLevel) {
return result;
}
+ @Override
+ public int updateParameterWithExpectedValue(Table table, String key, String
expectedValue, String newValue)
+ throws MetaException {
+ String dml = String.format(
Review Comment:
Setting `datanucleus.query.jdoql.allowAll=true` allows us to run UPDATE with
JDO query. I tried something like this but it doesn't work.
```java
Map<String, String> newParams = new HashMap<>(table.getParameters());
newParams.put(key, newValue);
openTransaction();
Query query = pm.newQuery("UPDATE
org.apache.hadoop.hive.metastore.model.MTable " +
"SET parameters=:newparams WHERE database.name == :dbname &&
tableName == :tblname && " +
"parameters.containsEntry(:key, :expval)");
int affectedRows = (int) query.executeWithMap(ImmutableMap.of(
"newparams", newParams,
"dbname", table.getDbName(),
"tblname", table.getTableName(),
"key", key,
"expval", expectedValue
));
```
The error is
```
Caused by:
org.datanucleus.store.rdbms.sql.expression.IllegalExpressionOperationException:
Cannot perform operation "==" on
org.datanucleus.store.rdbms.sql.expression.MapExpression@6f9c5048 and
org.datanucleus.store.rdbms.sql.expression.MapLiteral@5114b7c7
at
org.datanucleus.store.rdbms.sql.expression.SQLExpression.eq(SQLExpression.java:381)
at
org.datanucleus.store.rdbms.sql.expression.MapExpression.eq(MapExpression.java:80)
at
org.datanucleus.store.rdbms.query.QueryToSQLMapper.compileUpdate(QueryToSQLMapper.java:1134)
```
I believe it's because MapExpression only supports [eq with null literals in
DN](https://github.com/datanucleus/datanucleus-rdbms/blob/master/src/main/java/org/datanucleus/store/rdbms/sql/expression/MapExpression.java#L71).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]