예제 #1
0
 @Override
 public void update(QualifiedName name, DatabaseDto dto) {
   Session session = validateAndGetSession(name);
   log.info("Updating schema {}", name);
   try {
     metadataManager.updateSchema(session, new ConnectorSchemaMetadata(name.getDatabaseName()));
   } catch (PrestoException e) {
     if (e.getErrorCode() != StandardErrorCode.NOT_SUPPORTED.toErrorCode()) {
       throw e;
     }
   }
   if (dto != null && dto.getDefinitionMetadata() != null) {
     log.info("Saving user metadata for schema {}", name);
     userMetadataService.saveDefinitionMetadata(
         name, session.getUser(), Optional.of(dto.getDefinitionMetadata()), true);
   }
 }
예제 #2
0
  @Test
  public void testRowEquality() throws Exception {
    assertFunction(
        "test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10') = "
            + "test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10')",
        BOOLEAN,
        true);
    assertFunction(
        "test_row(1.0, test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10')) ="
            + "test_row(1.0, test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10'))",
        BOOLEAN,
        true);
    assertFunction("test_row(1.0, 'kittens') = test_row(1.0, 'kittens')", BOOLEAN, true);
    assertFunction("test_row(1, 2.0) = test_row(1, 2.0)", BOOLEAN, true);
    assertFunction(
        "test_row(TRUE, FALSE, TRUE, FALSE) = test_row(TRUE, FALSE, TRUE, FALSE)", BOOLEAN, true);
    assertFunction(
        "test_row(TRUE, FALSE, TRUE, FALSE) = test_row(TRUE, TRUE, TRUE, FALSE)", BOOLEAN, false);
    assertFunction(
        "test_row(1, 2.0, TRUE, 'kittens', from_unixtime(1)) = test_row(1, 2.0, TRUE, 'kittens', from_unixtime(1))",
        BOOLEAN,
        true);

    assertFunction(
        "test_row(1.0, test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10')) !="
            + "test_row(1.0, test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:11'))",
        BOOLEAN,
        true);
    assertFunction(
        "test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:10') != "
            + "test_row(TIMESTAMP '2001-01-02 03:04:05.321 +07:09', TIMESTAMP '2001-01-02 03:04:05.321 +07:11')",
        BOOLEAN,
        true);
    assertFunction("test_row(1.0, 'kittens') != test_row(1.0, 'kittens')", BOOLEAN, false);
    assertFunction("test_row(1, 2.0) != test_row(1, 2.0)", BOOLEAN, false);
    assertFunction(
        "test_row(TRUE, FALSE, TRUE, FALSE) != test_row(TRUE, FALSE, TRUE, FALSE)", BOOLEAN, false);
    assertFunction(
        "test_row(TRUE, FALSE, TRUE, FALSE) != test_row(TRUE, TRUE, TRUE, FALSE)", BOOLEAN, true);
    assertFunction(
        "test_row(1, 2.0, TRUE, 'kittens', from_unixtime(1)) != test_row(1, 2.0, TRUE, 'puppies', from_unixtime(1))",
        BOOLEAN,
        true);

    try {
      assertFunction(
          "test_row(cast(cast ('' as varbinary) as hyperloglog)) = test_row(cast(cast ('' as varbinary) as hyperloglog))",
          BOOLEAN,
          true);
      fail("hyperloglog is not comparable");
    } catch (SemanticException e) {
      if (!e.getMessage()
          .matches(
              "\\Qline 1:55: '=' cannot be applied to row<HyperLogLog>('col0'), row<HyperLogLog>('col0')\\E")) {
        throw e;
      }
      // Expected
    }

    assertFunction(
        "test_row(TRUE, ARRAY [1], MAP(ARRAY[1, 3], ARRAY[2.0, 4.0])) = test_row(TRUE, ARRAY [1, 2], MAP(ARRAY[1, 3], ARRAY[2.0, 4.0]))",
        BOOLEAN,
        false);
    assertFunction(
        "test_row(TRUE, ARRAY [1, 2], MAP(ARRAY[1, 3], ARRAY[2.0, 4.0])) = test_row(TRUE, ARRAY [1, 2], MAP(ARRAY[1, 3], ARRAY[2.0, 4.0]))",
        BOOLEAN,
        true);

    try {
      assertFunction("test_row(1, CAST(NULL AS BIGINT)) = test_row(1, 2)", BOOLEAN, false);
      fail("ROW comparison not implemented for NULL values");
    } catch (PrestoException e) {
      assertEquals(
          e.getErrorCode().getCode(), StandardErrorCode.NOT_SUPPORTED.toErrorCode().getCode());
    }

    assertFunction("test_row(TRUE, ARRAY [1]) = test_row(TRUE, ARRAY [1])", BOOLEAN, true);
    assertFunction("test_row(TRUE, ARRAY [1]) = test_row(TRUE, ARRAY [1,2])", BOOLEAN, false);
    assertFunction(
        "test_row(1.0, ARRAY [1,2,3], test_row(2,2.0)) = test_row(1.0, ARRAY [1,2,3], test_row(2,2.0))",
        BOOLEAN,
        true);

    assertFunction("test_row(TRUE, ARRAY [1]) != test_row(TRUE, ARRAY [1])", BOOLEAN, false);
    assertFunction("test_row(TRUE, ARRAY [1]) != test_row(TRUE, ARRAY [1,2])", BOOLEAN, true);
    assertFunction(
        "test_row(1.0, ARRAY [1,2,3], test_row(2,2.0)) != test_row(1.0, ARRAY [1,2,3], test_row(1,2.0))",
        BOOLEAN,
        true);
  }