adelapena commented on code in PR #2386:
URL: https://github.com/apache/cassandra/pull/2386#discussion_r1222888226


##########
src/java/org/apache/cassandra/cql3/functions/ToJsonFct.java:
##########
@@ -54,14 +54,28 @@ private ToJsonFct(String name, AbstractType<?> argType)
         super(name, UTF8Type.instance, argType);
     }
 
-    public ByteBuffer execute(ProtocolVersion protocolVersion, 
List<ByteBuffer> parameters) throws InvalidRequestException
+    @Override
+    public Arguments newArguments(ProtocolVersion version)
     {
-        assert parameters.size() == 1 : format("Expected 1 argument for %s(), 
but got %d", name.name, parameters.size());
-        ByteBuffer parameter = parameters.get(0);
-        if (parameter == null)
+        return new FunctionArguments(version, (protocolVersion, buffer) -> {
+            AbstractType<?> argType = argTypes.get(0);
+
+            if (buffer == null || (!buffer.hasRemaining() && 
argType.isEmptyValueMeaningless()))
+                return null;
+
+            return argTypes.get(0).toJSONString(buffer, protocolVersion);
+        });
+    }
+
+    @Override
+    public ByteBuffer execute(Arguments arguments) throws 
InvalidRequestException
+    {
+        assert arguments.size() == 1 : "Expected 1 argument for toJson(), but 
got " + arguments.size();

Review Comment:
   It isn't, the factory should have caught it before. Removed.



-- 
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]

Reply via email to