Java Code Examples for io.prestosql.spi.type.VarcharType#createVarcharType()
The following examples show how to use
io.prestosql.spi.type.VarcharType#createVarcharType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangerSystemAccessControlTest.java From ranger with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("PMD") public void testMisc() { assertEquals(accessControlManager.filterViewQueryOwnedBy(context(alice), queryOwners), queryOwners); // check {type} / {col} replacement final VarcharType varcharType = VarcharType.createVarcharType(20); Optional<ViewExpression> ret = accessControlManager.getColumnMask(context(alice), aliceTable, "cast_me", varcharType); assertNotNull(ret.get()); assertEquals(ret.get().getExpression(), "cast cast_me as varchar(20)"); ret = accessControlManager.getColumnMask(context(alice), aliceTable,"do-not-cast-me", varcharType); assertFalse(ret.isPresent()); ret = accessControlManager.getRowFilter(context(alice), aliceTable); assertFalse(ret.isPresent()); accessControlManager.checkCanExecuteFunction(context(alice), functionName); accessControlManager.checkCanGrantExecuteFunctionPrivilege(context(alice), functionName, new PrestoPrincipal(USER, "grantee"), true); accessControlManager.checkCanExecuteProcedure(context(alice), aliceProcedure); }
Example 2
Source File: VarcharParametricType.java From presto with Apache License 2.0 | 5 votes |
@Override public Type createType(TypeManager typeManager, List<TypeParameter> parameters) { if (parameters.isEmpty()) { return createUnboundedVarcharType(); } if (parameters.size() != 1) { throw new IllegalArgumentException("Expected exactly one parameter for VARCHAR"); } TypeParameter parameter = parameters.get(0); if (!parameter.isLongLiteral()) { throw new IllegalArgumentException("VARCHAR length must be a number"); } long length = parameter.getLongLiteral(); if (length == VarcharType.UNBOUNDED_LENGTH) { return VarcharType.createUnboundedVarcharType(); } if (length < 0 || length > VarcharType.MAX_LENGTH) { throw new IllegalArgumentException("Invalid VARCHAR length " + length); } return VarcharType.createVarcharType((int) length); }
Example 3
Source File: TestValueStore.java From presto with Apache License 2.0 | 5 votes |
@BeforeMethod(alwaysRun = true) public void setUp() { type = VarcharType.createVarcharType(100); BlockBuilder blockBuilder = type.createBlockBuilder(null, 100, 10); valueStore = new ValueStore(100, blockBuilder); valueStoreSmall = new ValueStore(1, blockBuilder); block = BlockAssertions.createStringsBlock("a", "b", "c", "d"); }
Example 4
Source File: TestMathFunctions.java From presto with Apache License 2.0 | 5 votes |
@Test public void testToBase() { VarcharType toBaseReturnType = VarcharType.createVarcharType(64); assertFunction("to_base(2147483648, 16)", toBaseReturnType, "80000000"); assertFunction("to_base(255, 2)", toBaseReturnType, "11111111"); assertFunction("to_base(-2147483647, 16)", toBaseReturnType, "-7fffffff"); assertFunction("to_base(NULL, 16)", toBaseReturnType, null); assertFunction("to_base(-2147483647, NULL)", toBaseReturnType, null); assertFunction("to_base(NULL, NULL)", toBaseReturnType, null); assertInvalidFunction("to_base(255, 1)", "Radix must be between 2 and 36"); }
Example 5
Source File: ExpressionAnalyzer.java From presto with Apache License 2.0 | 4 votes |
@Override protected Type visitStringLiteral(StringLiteral node, StackableAstVisitorContext<Context> context) { VarcharType type = VarcharType.createVarcharType(SliceUtf8.countCodePoints(node.getSlice())); return setExpressionType(node, type); }