public void prepareKeyspace(ClientState state) throws InvalidRequestException { if (!functionName.hasKeyspace() && state.getRawKeyspace() != null) functionName = new FunctionName(state.getKeyspace(), functionName.name); if (!functionName.hasKeyspace()) throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session"); ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace); stateFunc = new FunctionName(functionName.keyspace, stateFunc.name); if (finalFunc != null) finalFunc = new FunctionName(functionName.keyspace, finalFunc.name); }
public FunctionName asNativeFunction() { return FunctionName.nativeFunction(name); }
private static String stateFuncSig(FunctionName stateFuncName, CQL3Type.Raw stateTypeRaw, List<CQL3Type.Raw> argRawTypes) { StringBuilder sb = new StringBuilder(); sb.append(stateFuncName.toString()).append('(').append(stateTypeRaw); for (CQL3Type.Raw argRawType : argRawTypes) sb.append(", ").append(argRawType); sb.append(')'); return sb.toString(); }
throws InvalidRequestException if (name.equalsNativeFunction(TOKEN_FUNCTION_NAME)) return new TokenFct(Schema.instance.getCFMetaData(receiverKs, receiverCf)); if (name.equalsNativeFunction(ToJsonFct.NAME)) throw new InvalidRequestException("toJson() may only be used within the selection clause of SELECT statements"); if (name.equalsNativeFunction(FromJsonFct.NAME)) if (!name.hasKeyspace()) candidates.addAll(Schema.instance.getFunctions(name.asNativeFunction())); candidates.addAll(Schema.instance.getFunctions(new FunctionName(keyspace, name.name)));
public static FunctionName nativeFunction(String name) { return new FunctionName(SchemaConstants.SYSTEM_KEYSPACE_NAME, name); }
public final boolean equalsNativeFunction(FunctionName nativeFunction) { assert nativeFunction.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME); if (this.hasKeyspace() && !this.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME)) return false; return Objects.equal(this.name, nativeFunction.name); }
if (functionName.equalsNativeFunction(ToJsonFct.NAME)) else if (functionName.equalsNativeFunction(FunctionName.nativeFunction("count")) && preparedArgs.size() == 1 && (preparedArgs.get(0) instanceof WithTerm)
public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver) { // Note: Functions.get() will return null if the function doesn't exist, or throw is no function matching // the arguments can be found. We may get one of those if an undefined/wrong function is used as argument // of another, existing, function. In that case, we return true here because we'll throw a proper exception // later with a more helpful error message that if we were to return false here. try { Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type); // Because fromJson() can return whatever type the receiver is, we'll always get EXACT_MATCH. To // handle potentially ambiguous function calls with fromJson() as an argument, always return // WEAKLY_ASSIGNABLE to force the user to typecast if necessary if (fun != null && fun.name().equals(FromJsonFct.NAME)) return TestResult.WEAKLY_ASSIGNABLE; if (fun != null && receiver.type.equals(fun.returnType())) return AssignmentTestable.TestResult.EXACT_MATCH; else if (fun == null || receiver.type.isValueCompatibleWith(fun.returnType())) return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE; else return AssignmentTestable.TestResult.NOT_ASSIGNABLE; } catch (InvalidRequestException e) { return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE; } }
throws InvalidRequestException if (name.equalsNativeFunction(TOKEN_FUNCTION_NAME)) return new TokenFct(Schema.instance.getCFMetaData(receiverKs, receiverCf)); if (name.equalsNativeFunction(ToJsonFct.NAME)) throw new InvalidRequestException("toJson() may only be used within the selection clause of SELECT statements"); if (name.equalsNativeFunction(FromJsonFct.NAME)) if (!name.hasKeyspace()) candidates.addAll(Schema.instance.getFunctions(name.asNativeFunction())); candidates.addAll(Schema.instance.getFunctions(new FunctionName(keyspace, name.name)));
public static FunctionName nativeFunction(String name) { return new FunctionName(SchemaConstants.SYSTEM_KEYSPACE_NAME, name); }
public final boolean equalsNativeFunction(FunctionName nativeFunction) { assert nativeFunction.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME); if (this.hasKeyspace() && !this.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME)) return false; return Objects.equal(this.name, nativeFunction.name); }
if (functionName.equalsNativeFunction(ToJsonFct.NAME)) else if (functionName.equalsNativeFunction(FunctionName.nativeFunction("count")) && preparedArgs.size() == 1 && (preparedArgs.get(0) instanceof WithTerm)
public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver) { // Note: Functions.get() will return null if the function doesn't exist, or throw is no function matching // the arguments can be found. We may get one of those if an undefined/wrong function is used as argument // of another, existing, function. In that case, we return true here because we'll throw a proper exception // later with a more helpful error message that if we were to return false here. try { Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type); // Because fromJson() can return whatever type the receiver is, we'll always get EXACT_MATCH. To // handle potentially ambiguous function calls with fromJson() as an argument, always return // WEAKLY_ASSIGNABLE to force the user to typecast if necessary if (fun != null && fun.name().equals(FromJsonFct.NAME)) return TestResult.WEAKLY_ASSIGNABLE; if (fun != null && receiver.type.equals(fun.returnType())) return AssignmentTestable.TestResult.EXACT_MATCH; else if (fun == null || receiver.type.isValueCompatibleWith(fun.returnType())) return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE; else return AssignmentTestable.TestResult.NOT_ASSIGNABLE; } catch (InvalidRequestException e) { return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE; } }
public void prepareKeyspace(ClientState state) throws InvalidRequestException { if (!functionName.hasKeyspace() && state.getRawKeyspace() != null) functionName = new FunctionName(state.getKeyspace(), functionName.name); if (!functionName.hasKeyspace()) throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session"); ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace); stateFunc = new FunctionName(functionName.keyspace, stateFunc.name); if (finalFunc != null) finalFunc = new FunctionName(functionName.keyspace, finalFunc.name); }
throws InvalidRequestException if (name.equalsNativeFunction(TOKEN_FUNCTION_NAME)) return new TokenFct(Schema.instance.getCFMetaData(receiverKs, receiverCf)); if (name.equalsNativeFunction(ToJsonFct.NAME)) throw new InvalidRequestException("toJson() may only be used within the selection clause of SELECT statements"); if (name.equalsNativeFunction(FromJsonFct.NAME)) if (!name.hasKeyspace()) candidates.addAll(Schema.instance.getFunctions(name.asNativeFunction())); candidates.addAll(Schema.instance.getFunctions(new FunctionName(keyspace, name.name)));
public static FunctionName nativeFunction(String name) { return new FunctionName(SchemaConstants.SYSTEM_KEYSPACE_NAME, name); }
private static String stateFuncSig(FunctionName stateFuncName, CQL3Type.Raw stateTypeRaw, List<CQL3Type.Raw> argRawTypes) { StringBuilder sb = new StringBuilder(); sb.append(stateFuncName.toString()).append('(').append(stateTypeRaw); for (CQL3Type.Raw argRawType : argRawTypes) sb.append(", ").append(argRawType); sb.append(')'); return sb.toString(); }
public FunctionName asNativeFunction() { return FunctionName.nativeFunction(name); }
public final boolean equalsNativeFunction(FunctionName nativeFunction) { assert nativeFunction.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME); if (this.hasKeyspace() && !this.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME)) return false; return Objects.equal(this.name, nativeFunction.name); }
if (functionName.equalsNativeFunction(FunctionName.nativeFunction("count")) && preparedArgs.size() == 1 && (preparedArgs.get(0) instanceof WithTerm)