muttakin2301/ccr2000 huggingface dataset:
Code review comment: It's fine to me, we only read serial from PG and wont write a serial column.

Code under review:
public static TestTable getSerialTable() {
		return new TestTable(
			TableSchema.builder()
				.field("f0", DataTypes.SMALLINT())
				.field("f1", DataTypes.INT())
				.field("f2", DataTypes.SMALLINT())
				.field("f3", DataTypes.INT())
				.field("f4", DataTypes.BIGINT())
				.field("f5", DataTypes.BIGINT())
				.build(),
			"f0 smallserial, " +
				"f1 serial, " +
				"f2 serial2, " +
				"f3 serial4, " +
				"f4 serial8, " +
				"f5 bigserial",
			"0," +
				"1," +
				"2," +
				"3," +
				"4," +
				"5"
		);
	}

Line commented on: "5"

Revised code:
public static TestTable getSerialTable() {
		return new TestTable(
			TableSchema.builder()
				
				.field("f0", DataTypes.SMALLINT().notNull())
				.field("f1", DataTypes.INT().notNull())
				.field("f2", DataTypes.SMALLINT().notNull())
				.field("f3", DataTypes.INT().notNull())
				.field("f4", DataTypes.BIGINT().notNull())
				.field("f5", DataTypes.BIGINT().notNull())
				.build(),
			"f0 smallserial, " +
				"f1 serial, " +
				"f2 serial2, " +
				"f3 serial4, " +
				"f4 serial8, " +
				"f5 bigserial",
			"32767," +
				"2147483647," +
				"32767," +
				"2147483647," +
				"9223372036854775807," +
				"9223372036854775807"
		);
	}
Code review comment: The returned `NodeMetrics` object is shared and thus may be read outside the lock whilst concurrently being updated by another thread. Is this a problem? Should we deep-copy the metrics to make sure they're internally consistent? This is not something introduced by this PR, but just a general observation.

Code under review:
public Node getRecipient(List<Mirror.Entry> choices) {
        if (choices.isEmpty()) return null;

        double weightSum = 0.0;
        Node selectedNode = null;
        synchronized (this) {
            for (Mirror.Entry entry : choices) {
                NodeMetrics nodeMetrics = getNodeMetrics(entry);

                weightSum += nodeMetrics.weight;

                if (weightSum > position) {
                    selectedNode = new Node(entry, nodeMetrics);
                    break;
                }
            }
            if (selectedNode == null) { 
                position -= weightSum;
                selectedNode = new Node(choices.get(0), getNodeMetrics(choices.get(0)));
            }
            position += 1.0;
            selectedNode.metrics.sent++;
        }
        return selectedNode;
    }

Line commented on: selectedNode = new Node(entry, nodeMetrics);

Revised code:
public Node getRecipient(List<Mirror.Entry> choices) {
        if (choices.isEmpty()) return null;

        double weightSum = 0.0;
        Node selectedNode = null;
        synchronized (this) {
            for (Mirror.Entry entry : choices) {
                NodeMetrics nodeMetrics = getNodeMetrics(entry);

                weightSum += nodeMetrics.weight;

                if (weightSum > position) {
                    selectedNode = new Node(entry, nodeMetrics);
                    break;
                }
            }
            if (selectedNode == null) { 
                position -= weightSum;
                selectedNode = new Node(choices.get(0), getNodeMetrics(choices.get(0)));
            }
            position += 1.0;
            selectedNode.metrics.sent++;
        }
        return selectedNode;
    }
Code review comment: Do you think we should add a new method in `ExceptionUtils` to represent this meaning?

Code under review:
private void ensureRunning() throws Exception {
        
        
        if (wasClosed || !thread.isAlive()) {
            cleanupRequests();
            IllegalStateException exception = new IllegalStateException("not running");
            if (thrown != null) {
                exception.addSuppressed(thrown);
            }
            throw exception;
        }
    }

Line commented on: IllegalStateException exception = new IllegalStateException("not running");

Revised code:
private void ensureRunning() throws Exception {
        
        
        if (wasClosed || !thread.isAlive()) {
            cleanupRequests();
            IllegalStateException exception = new IllegalStateException("not running");
            if (thrown != null) {
                exception.addSuppressed(thrown);
            }
            throw exception;
        }
    }
Code review comment: Even though the operator precedence is well defined here, I think it could be good to have some parentheses to be entirely explicit about the intention

Code under review:
public double getRetryDelay(int retry) {
        long retryMultiplier = 0l;
        if (retry > 1) {
            retryMultiplier = Math.min(10000, 1L << (retry-1));
        }

        return Math.min(10.0, retryMultiplier*baseDelayUS.get()/US);
    }

Line commented on: return Math.min(10.0, retryMultiplier*baseDelayUS.get()/US);

Revised code:
public double getRetryDelay(int retry) {
        long retryMultiplier = 0l;
        if (retry > 1) {
            retryMultiplier = 1L << Math.min(20, retry-1);
        }

        return Math.min(10.0, (retryMultiplier*baseDelayUS.get())/US);
    }
Code review comment: According to the spec yes, but in quarkus, if `quarkus.arc.transform-unproxyable-classes=true` (default value) the `final` modifier is simply removed and the method is intercepted. It should be tested in the `io.quarkus.security.test.cdi.SecurityAnnotationOnFinalMethodTest`.

Code under review:
void forEachMethod(ClassInfo clazz, Consumer<MethodInfo> action) {
        for (MethodInfo method : clazz.methods()) {
            if (method.name().startsWith("<")) {
                
                continue;
            }
            if (Modifier.isPrivate(method.flags())) {
                
                continue;
            }
            if (Modifier.isFinal(method.flags())) {
                
                continue;
            }
            if (method.isSynthetic()) {
                
                continue;
            }

            action.accept(method);
        }

        DotName parentClassName = clazz.superName();
        if (parentClassName == null || parentClassName.equals(DotNames.OBJECT)) {
            return;
        }
        ClassInfo parentClass = index.getClassByName(parentClassName);
        if (parentClass == null) {
            return;
        }
        forEachMethod(parentClass, action);
    }


Revised code:
void forEachMethod(ClassInfo clazz, Consumer<MethodInfo> action) {
        for (MethodInfo method : clazz.methods()) {
            if (method.name().startsWith("<")) {
                
                continue;
            }
            if (method.isSynthetic()) {
                
                continue;
            }

            action.accept(method);
        }

        DotName parentClassName = clazz.superName();
        if (parentClassName == null || parentClassName.equals(DotNames.OBJECT)) {
            return;
        }
        ClassInfo parentClass = index.getClassByName(parentClassName);
        if (parentClass == null) {
            return;
        }
        forEachMethod(parentClass, action);
    }
Code review comment: I don't think we should. It's more like a fire-and-forget style of communication...

Code under review:
public CompletionStage<Void> invoke(ScheduledExecution execution) throws Exception {
        if (running.compareAndSet(false, true)) {
            return delegate.invoke(execution).whenComplete((r, t) -> running.set(false));
        }
        LOG.debugf("Skipped scheduled invoker execution: %s", delegate.getClass().getName());
        SkippedExecution payload = new SkippedExecution(execution,
                "The scheduled method should not be executed concurrently");
        event.fire(payload);
        event.fireAsync(payload);
        return CompletableFuture.completedStage(null);
    }

Line commented on: event.fireAsync(payload);

Revised code:
public CompletionStage<Void> invoke(ScheduledExecution execution) throws Exception {
        if (running.compareAndSet(false, true)) {
            return delegate.invoke(execution).whenComplete((r, t) -> running.set(false));
        }
        LOG.debugf("Skipped scheduled invoker execution: %s", delegate.getClass().getName());
        SkippedExecution payload = new SkippedExecution(execution,
                "The scheduled method should not be executed concurrently");
        event.fire(payload);
        event.fireAsync(payload);
        return CompletableFuture.completedStage(null);
    }
Code review comment: this may throw java.lang.ClassCastException. It is better to compare their class before convert.

Code under review:
public boolean equals(Object o) {
        if (!super.equals(o)) {
            return false;
        }
        VarcharType that = (VarcharType) o;
        return len == that.len;
    }

Line commented on: VarcharType that = (VarcharType) o;

Revised code:
public boolean equals(Object o) {
        if (!super.equals(o)) {
            return false;
        }
        VarcharType that = (VarcharType) o;
        return len == that.len;
    }
Code review comment: I think we can add the constant for `CompressedSourceTest.java` at least.

Code under review:
public void testEmptyLzoProgress() throws IOException {
    File tmpFile = tmpFolder.newFile("empty.lzo_deflate");
    String filename = tmpFile.toPath().toString();
    writeFile(tmpFile, new byte[0], CompressionMode.LZO);

    PipelineOptions options = PipelineOptionsFactory.create();
    CompressedSource<Byte> source =
        CompressedSource.from(new ByteSource(filename, 1)).withDecompression(CompressionMode.LZO);
    try (BoundedReader<Byte> readerOrig = source.createReader(options)) {
      assertThat(readerOrig, instanceOf(CompressedReader.class));
      CompressedReader<Byte> reader = (CompressedReader<Byte>) readerOrig;
      
      assertEquals(0.0, reader.getFractionConsumed(), 1e-6);
      assertEquals(0, reader.getSplitPointsConsumed());
      assertEquals(1, reader.getSplitPointsRemaining());
      
      assertFalse(reader.start());
      
      assertEquals(1.0, reader.getFractionConsumed(), 1e-6);
      assertEquals(0, reader.getSplitPointsConsumed());
      assertEquals(0, reader.getSplitPointsRemaining());
    }
  }

Line commented on: assertEquals(0.0, reader.getFractionConsumed(), 1e-6);

Revised code:
public void testEmptyLzoProgress() throws IOException {
    File tmpFile = tmpFolder.newFile("empty.lzo_deflate");
    String filename = tmpFile.toPath().toString();
    writeFile(tmpFile, new byte[0], CompressionMode.LZO);

    PipelineOptions options = PipelineOptionsFactory.create();
    CompressedSource<Byte> source =
        CompressedSource.from(new ByteSource(filename, 1)).withDecompression(CompressionMode.LZO);
    try (BoundedReader<Byte> readerOrig = source.createReader(options)) {
      assertThat(readerOrig, instanceOf(CompressedReader.class));
      CompressedReader<Byte> reader = (CompressedReader<Byte>) readerOrig;
      
      assertEquals(0.0, reader.getFractionConsumed(), delta);
      assertEquals(0, reader.getSplitPointsConsumed());
      assertEquals(1, reader.getSplitPointsRemaining());
      
      assertFalse(reader.start());
      
      assertEquals(1.0, reader.getFractionConsumed(), delta);
      assertEquals(0, reader.getSplitPointsConsumed());
      assertEquals(0, reader.getSplitPointsRemaining());
    }
  }
Code review comment: How about  ```         Preconditions.checkState(                 serializedJobInformation instanceof NonOffloaded,                  "Trying to work with offloaded serialized job information.");         NonOffloaded<JobInformation> jobInformation =                 (NonOffloaded<JobInformation>) serializedJobInformation;         return jobInformation.serializedValue.deserializeValue(getClass().getClassLoader());   ```  ?

Code under review:
public TaskInformation getTaskInformation() throws IOException, ClassNotFoundException {
        if (taskInformation != null) {
            return taskInformation;
        }
        if (serializedTaskInformation instanceof NonOffloaded) {
            NonOffloaded<TaskInformation> taskInformation =
                    (NonOffloaded<TaskInformation>) serializedTaskInformation;
            return taskInformation.serializedValue.deserializeValue(getClass().getClassLoader());
        }
        throw new IllegalStateException(
                "Trying to work with offloaded serialized task information.");
    }

Line commented on: "Trying to work with offloaded serialized task information.");

Revised code:
public TaskInformation getTaskInformation() throws IOException, ClassNotFoundException {
        if (taskInformation != null) {
            return taskInformation;
        }
        if (serializedTaskInformation instanceof NonOffloaded) {
            NonOffloaded<TaskInformation> taskInformation =
                    (NonOffloaded<TaskInformation>) serializedTaskInformation;
            return taskInformation.serializedValue.deserializeValue(getClass().getClassLoader());
        }
        throw new IllegalStateException(
                "Trying to work with offloaded serialized task information.");
    }
Code review comment: Thanks! Let's try this then ...

Code under review:
public void close() {
        if (closed.get()) return;
        closed.set(true);
        synchronized (nodeTable.writeLock) {
            synchronized (clusterTable.writeLock) {
                for (SqlCompiler sqlCompiler : sqlCompilerPool)
                    sqlCompiler.close();
                engine.close();
            }
        }
    }

Line commented on: closed.set(true);

Revised code:
public void close() {
        if (closed.getAndSet(true)) return;
        synchronized (nodeTable.writeLock) {
            synchronized (clusterTable.writeLock) {
                for (SqlCompiler sqlCompiler : sqlCompilerPool)
                    sqlCompiler.close();
                engine.close();
            }
        }
    }
Code review comment: Hi @pnowojski , thanks for your analysis!  > I would move: SinkWriterOperatorFactory.class.getName().equals(streamOperatorFactoryClassName) > check, into the boolean StreamConfig#isSinkWriterOperatorFactory(Class<...> ...) method.  > It doesn't fit there very well, BUT at least it would justify why we have the checkState in the  > StreamConfig#setStreamOperatorFactory.  The solution1 (`SinkWriterOperatorFactory.class.getName().equals(streamOperatorFactoryClassName)` ) is still fragile, right?  When `makes SinkWriterOperatorFactory non final and implement a subclass` in the future, it still cannot support, and silently.   > toBeSerializedConfigObjects.put(SERIALIZED_UDF, factory); config.setString(IS_INSTANCE_OF_SinkWriterOperatorFactory, factory instance of SinkWriterOperatorFactory); > would be better/cleaner. Either one is fine for me.  The solution2 is perfectly compatible with the case of adding sub class.  However, as I said before, `the getStreamOperatorFactory is called in the toString to print the class name.`, and I'd like to using the `SERIALIZED_UDF_CLASS_NAME` instead of `getStreamOperatorFactory`.  If we just keep `IS_INSTANCE_OF_SinkWriterOperatorFactory`, we must call `getStreamOperatorFactory` in the `toString` method.  Or we add the `IS_INSTANCE_OF_SinkWriterOperatorFactory` and `SERIALIZED_UDF_CLASS_NAME` together?   Actually, I have solution3 before I create this PR:  We store the `SERIALIZED_UDF_CLASS` instead of `SERIALIZED_UDF_CLASS_NAME`.  ``` # setStreamOperatorFactory method toBeSerializedConfigObjects.put(SERIALIZED_UDF, factory); toBeSerializedConfigObjects.put(SERIALIZED_UDF_CLASS, factory.getClass()); ```   ```     public <T extends StreamOperatorFactory<?>> Class<T> getStreamOperatorFactoryClass(ClassLoader cl) {         try {             return InstantiationUtil.readObjectFromConfig(this.config, SERIALIZED_UDF_CLASS, cl);         } catch (Exception e) {             throw new StreamTaskException("Could not instantiate chained outputs.", e);         }     } ```  And check `isAssignableFrom`:  ``` SinkWriterOperatorFactory.class.isAssignableFrom(getStreamOperatorFactoryClass(SinkWriterOperatorFactory.class.getClassLoader())); ```  The solution3 is fine, however, I'm worried that when there are multiple classloaders, the judgment may be wrong.  That's why this PR store the ClassName instead of Class.   WDYT?

Code under review:
public void setStreamOperatorFactory(StreamOperatorFactory<?> factory) {
        if (factory != null) {
            toBeSerializedConfigObjects.put(SERIALIZED_UDF, factory);
            config.setString(SERIALIZED_UDF_CLASS_NAME, factory.getClass().getName());
        }
    }

Line commented on: config.setString(SERIALIZED_UDF_CLASS_NAME, factory.getClass().getName());

Revised code:
public void setStreamOperatorFactory(StreamOperatorFactory<?> factory) {
        if (factory != null) {
            toBeSerializedConfigObjects.put(SERIALIZED_UDF, factory);
            config.setString(SERIALIZED_UDF_CLASS_NAME, factory.getClass().getName());
        }
    }
Code review comment: what is the difference between DUPLICATE_CREATE_TASK and TAKS_EXISTS?

Code under review:
public long createTask(Task task) {
        if (!tryLock()) {
            return TASK_CREATE_TIMEOUT;
        }
        try {
            if (nameToTaskMap.containsKey(task.getName())) {
                return TASK_EXISTS;
            }
            nameToTaskMap.put(task.getName(), task);
            if (manualTaskMap.containsKey(task.getId())) {
                return DUPLICATE_CREATE_TASK;
            }
            manualTaskMap.put(task.getId(), task);
            
            return task.getId();
        } finally {
            unlock();
        }
    }

Line commented on: return TASK_EXISTS;

Revised code:
public long createTask(Task task) {
        if (!tryLock()) {
            return GET_TASK_LOCK_FAILED;
        }
        try {
            if (nameToTaskMap.containsKey(task.getName())) {
                return TASK_EXISTS;
            }
            nameToTaskMap.put(task.getName(), task);
            if (manualTaskMap.containsKey(task.getId())) {
                return DUPLICATE_CREATE_TASK;
            }
            manualTaskMap.put(task.getId(), task);
            
            return task.getId();
        } finally {
            unlock();
        }
    }
Code review comment: I agree with you - your solution was more elegant. But we try to avoid lambdas for efficiency reasons. Of course we're not extreme about it: lambdas are a fine solution when they are a good solution, but I still tend to prefer avoiding them in such situations.

Code under review:
protected ConnectionProvider selectConnectionProvider(final String tenantIdentifier) {
        LOG.debugv("selectConnectionProvider({0})", tenantIdentifier);

        ConnectionProvider provider = providerMap.get(tenantIdentifier);
        if (provider == null) {
            final ConnectionProvider connectionProvider = resolveConnectionProvider(tenantIdentifier);
            providerMap.put(tenantIdentifier, connectionProvider);
            return connectionProvider;
        }
        return provider;

    }

Line commented on: final ConnectionProvider connectionProvider = resolveConnectionProvider(tenantIdentifier);

Revised code:
protected ConnectionProvider selectConnectionProvider(final String tenantIdentifier) {
        LOG.debugv("selectConnectionProvider({0})", tenantIdentifier);

        ConnectionProvider provider = providerMap.get(tenantIdentifier);
        if (provider == null) {
            final ConnectionProvider connectionProvider = resolveConnectionProvider(tenantIdentifier);
            providerMap.put(tenantIdentifier, connectionProvider);
            return connectionProvider;
        }
        return provider;

    }
Code review comment: Hi, @terrymanu, I've addressed your concern. Please help to take another look. Thanks

Code under review:
void assertUnmarshalYamlAgentConfiguration() {
        InputStream inputStream = getClass().getResourceAsStream("/conf/agent.yaml");
        YamlAgentConfiguration actual = AgentYamlEngine.unmarshalYamlAgentConfiguration(inputStream);
        
        assertNotNull(actual);
    }

Line commented on: assertNotNull(actual);

Revised code:
void assertUnmarshalYamlAgentConfiguration() throws IOException {
        try (InputStream inputStream = Files.newInputStream(new File(getResourceURL(), "/conf/agent.yaml").toPath())) {
            YamlAgentConfiguration yamlAgentConfig = AgentYamlEngine.unmarshalYamlAgentConfiguration(inputStream);
            Map<String, PluginConfiguration> actual = YamlPluginsConfigurationSwapper.swap(yamlAgentConfig);
            assertThat(actual.size(), is(3));
            assertLogFixturePluginConfiguration(actual.get("log_fixture"));
            assertMetricsPluginConfiguration(actual.get("metrics_fixture"));
            assertTracingPluginConfiguration(actual.get("tracing_fixture"));
        }
    }
Code review comment: Yes, the `length` check is moved to the constructor of `SqlShowDatabases`, and I added a test case to catch the exception in `catalog_database.q `

Code under review:
public Operation convertSqlNode(SqlShowDatabases sqlShowDatabases, ConvertContext context) {
        if (sqlShowDatabases.getPreposition() == null) {
            return new ShowDatabasesOperation(
                    sqlShowDatabases.getLikeType(),
                    sqlShowDatabases.getLikeSqlPattern(),
                    sqlShowDatabases.isNotLike());
        } else {
            CatalogManager catalogManager = context.getCatalogManager();
            String[] fullCatalogName = sqlShowDatabases.getCatalog();
            if (fullCatalogName.length > 1) {
                throw new ValidationException(
                        String.format(
                                "Show databases from/in identifier [ %s ] format error, catalog cannot contain dot character.",
                                String.join(".", fullCatalogName)));
            }
            String catalogName =
                    fullCatalogName.length == 0
                            ? catalogManager.getCurrentCatalog()
                            : fullCatalogName[0];
            return new ShowDatabasesOperation(
                    sqlShowDatabases.getPreposition(),
                    catalogName,
                    sqlShowDatabases.getLikeType(),
                    sqlShowDatabases.getLikeSqlPattern(),
                    sqlShowDatabases.isNotLike());
        }
    }

Line commented on: if (fullCatalogName.length > 1) {

Revised code:
public Operation convertSqlNode(SqlShowDatabases sqlShowDatabases, ConvertContext context) {
        if (sqlShowDatabases.getPreposition() == null) {
            return new ShowDatabasesOperation(
                    sqlShowDatabases.getLikeType(),
                    sqlShowDatabases.getLikeSqlPattern(),
                    sqlShowDatabases.isNotLike());
        } else {
            return new ShowDatabasesOperation(
                    sqlShowDatabases.getCatalog()[0],
                    sqlShowDatabases.getLikeType(),
                    sqlShowDatabases.getLikeSqlPattern(),
                    sqlShowDatabases.isNotLike());
        }
    }
Code review comment: We don't have this API anymore. What if we extract the defaultable parameters and check?

Code under review:
public void testFunctionType() {
        Symbol symbol = getSymbol(43, 12);
        FunctionTypeDescriptor type = ((FunctionSymbol) symbol).typeDescriptor();
        assertEquals(type.kind(), TypeDescKind.FUNCTION);

        List<Parameter> parameters = type.parameters();
        assertEquals(parameters.size(), 2);
        validateParam(parameters.get(0), "x", REQUIRED, INT);

        Parameter restParam = type.restParam().get();
        validateParam(restParam, "rest", REST, ARRAY);

        BallerinaTypeDescriptor returnType = type.returnTypeDescriptor().get();
        assertEquals(returnType.kind(), INT);
    }

Line commented on: BallerinaTypeDescriptor returnType = type.returnTypeDescriptor().get();

Revised code:
public void testFunctionType() {
        Symbol symbol = getSymbol(43, 12);
        FunctionTypeDescriptor type = ((FunctionSymbol) symbol).typeDescriptor();
        assertEquals(type.kind(), TypeDescKind.FUNCTION);

        List<Parameter> parameters = type.parameters();
        assertEquals(parameters.size(), 2);
        validateParam(parameters.get(0), "x", REQUIRED, INT);

        Parameter restParam = type.restParam().get();
        validateParam(restParam, "rest", REST, ARRAY);

        BallerinaTypeDescriptor returnType = type.returnTypeDescriptor().get();
        assertEquals(returnType.kind(), INT);
    }
Code review comment: You're right! Let me fix that

Code under review:
public void start(Future<Void> startFuture) throws Exception {
            final AtomicInteger remainingCount = new AtomicInteger(httpsOptions != null ? 2 : 1);
            final HttpServerStartHandler httpServerStartHandler = new HttpServerStartHandler(startFuture, httpOptions,
                    remainingCount);
            httpServer = vertx.createHttpServer(httpOptions);
            httpServer.requestHandler(router);
            httpServer.listen(port, host, httpServerStartHandler);
            if (httpsOptions != null) {
                httpsServer = vertx.createHttpServer(httpsOptions);
                httpsServer.requestHandler(router);
                httpsServer.listen(httpsPort, host, httpServerStartHandler);
            }
        }

Line commented on: remainingCount);

Revised code:
public void start(Future<Void> startFuture) {
            final AtomicInteger remainingCount = new AtomicInteger(httpsOptions != null ? 2 : 1);
            httpServer = vertx.createHttpServer(httpOptions);
            httpServer.requestHandler(router);
            httpServer.listen(port, host, event -> {
                if (event.cause() != null) {
                    startFuture.fail(event.cause());
                } else {
                    
                    httpOptions.setPort(event.result().actualPort());
                    if (remainingCount.decrementAndGet() == 0) {
                        startFuture.complete(null);
                    }
                }
            });
            if (httpsOptions != null) {
                httpsServer = vertx.createHttpServer(httpsOptions);
                httpsServer.requestHandler(router);
                httpsServer.listen(httpsPort, host, event -> {
                    if (event.cause() != null) {
                        startFuture.fail(event.cause());
                    } else {
                        httpsOptions.setPort(event.result().actualPort());
                        if (remainingCount.decrementAndGet() == 0) {
                            startFuture.complete();
                        }
                    }
                });
            }
        }
Code review comment: Please use assertThat and InstanceOf to assert

Code under review:
public void assertRightMysqlSchemaDataSources() throws Exception {
        
        JDBCRawBackendDataSourceFactory jdbcRawBackendDataSourceFactory = Mockito.mock(JDBCRawBackendDataSourceFactory.class);
        Mockito.when(jdbcRawBackendDataSourceFactory.build(Mockito.anyString(), Mockito.any())).thenReturn(new HikariDataSource());
        ProxyDataSourceContext proxyDataSourceContext = build(jdbcRawBackendDataSourceFactory);
        assertTrue(proxyDataSourceContext.getDatabaseType() instanceof MySQLDatabaseType);
        assertTrue(proxyDataSourceContext.getDataSourcesMap().size() == 1);
        Mockito.reset(jdbcRawBackendDataSourceFactory);
    }

Line commented on: assertTrue(proxyDataSourceContext.getDatabaseType() instanceof MySQLDatabaseType);

Revised code:
public void assertRightMysqlSchemaDataSources() throws Exception {
        JDBCRawBackendDataSourceFactory jdbcRawBackendDataSourceFactory = mock(JDBCRawBackendDataSourceFactory.class);
        when(jdbcRawBackendDataSourceFactory.build(anyString(), any())).thenReturn(new HikariDataSource());
        ProxyDataSourceContext proxyDataSourceContext = build(jdbcRawBackendDataSourceFactory);
        assertThat(proxyDataSourceContext.getDatabaseType(), instanceOf(MySQLDatabaseType.class));
        assertTrue(proxyDataSourceContext.getDataSourcesMap().size() == 1);
        reset(jdbcRawBackendDataSourceFactory);
    }
Code review comment: This is going to count as a crash in our SLO monitoring. Can you actually get here or is this rejected by the parser? If you can actually get here you might throw a `UnsupportedOperationException`, if you can't actually get here consider `IllegalArgumentException` (which will still count as a crash but makes it clear it isn't a problem with this code).

Code under review:
void validateJavaUdf(ResolvedNodes.ResolvedCreateFunctionStmt createFunctionStmt) {
    for (FunctionArgumentType argumentType :
        createFunctionStmt.getSignature().getFunctionArgumentList()) {
      Type type = argumentType.getType();
      if (type == null) {
        throw new UnsupportedOperationException("UDF templated argument types are not supported.");
      }
      validateJavaUdfZetaSqlType(type);
    }
    if (createFunctionStmt.getReturnType() == null) {
      throw new NullPointerException("UDF return type must not be null.");
    }
    validateJavaUdfZetaSqlType(createFunctionStmt.getReturnType());
  }

Line commented on: throw new NullPointerException("UDF return type must not be null.");

Revised code:
void validateJavaUdf(ResolvedNodes.ResolvedCreateFunctionStmt createFunctionStmt) {
    for (FunctionArgumentType argumentType :
        createFunctionStmt.getSignature().getFunctionArgumentList()) {
      Type type = argumentType.getType();
      if (type == null) {
        throw new UnsupportedOperationException("UDF templated argument types are not supported.");
      }
      validateJavaUdfZetaSqlType(type);
    }
    if (createFunctionStmt.getReturnType() == null) {
      throw new IllegalArgumentException("UDF return type must not be null.");
    }
    validateJavaUdfZetaSqlType(createFunctionStmt.getReturnType());
  }
Code review comment: db or full db only need one?

Code under review:
public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TableName tableName = (TableName) o;
        return Objects.equals(catalog, tableName.catalog)
                && Objects.equals(tbl, tableName.tbl)
                && Objects.equals(db, tableName.db)
                && Objects.equals(fullDb, tableName.fullDb);
    }

Line commented on: && Objects.equals(db, tableName.db)

Revised code:
public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TableName tableName = (TableName) o;
        return Objects.equals(catalog, tableName.catalog)
                && Objects.equals(tbl, tableName.tbl)
                && Objects.equals(db, tableName.db);
    }
Code review comment: I was confused because I don't see where the test attempts to catch the failure via try/catch or ExpectedException test rule.

Code under review:
public IntervalWindow assignWindow(Instant timestamp) {
      return new IntervalWindow(
          BoundedWindow.TIMESTAMP_MIN_VALUE, GlobalWindow.INSTANCE.maxTimestamp());
    }

Line commented on: BoundedWindow.TIMESTAMP_MIN_VALUE, GlobalWindow.INSTANCE.maxTimestamp());

Revised code:
public IntervalWindow assignWindow(Instant timestamp) {
      return new IntervalWindow(
          BoundedWindow.TIMESTAMP_MIN_VALUE, GlobalWindow.INSTANCE.maxTimestamp());
    }
Code review comment: Good point, I can try. Without this I got an exception telling me I had to chunk it, but yeah, you're probably right that the header should be enough. If AsyncFile gives me the file size.

Code under review:
public void writeResponse(AsyncFile file, Type genericType, ServerRequestContext context) throws WebApplicationException {
        ResteasyReactiveRequestContext ctx = ((ResteasyReactiveRequestContext) context);
        ctx.suspend();
        ServerHttpResponse response = context.serverResponse();
        response.setChunked(true);
        file.handler(buffer -> {
            try {
                response.write(buffer.getBytes());
            } catch (Exception x) {
                
                ctx.resume(x);
                return;
            }
            if (response.isWriteQueueFull()) {
                file.pause();
                response.addDrainHandler(new Runnable() {
                    @Override
                    public void run() {
                        file.resume();
                    }
                });
            }
        });

        file.endHandler(new Handler<Void>() {
            @Override
            public void handle(Void event) {
                response.end();
                
                ctx.resume();
            }
        });
    }

Line commented on: response.setChunked(true);

Revised code:
public void writeResponse(AsyncFile file, Type genericType, ServerRequestContext context) throws WebApplicationException {
        ResteasyReactiveRequestContext ctx = ((ResteasyReactiveRequestContext) context);
        ctx.suspend();
        ServerHttpResponse response = context.serverResponse();
        
        if (file.getReadLength() != Long.MAX_VALUE) {
            response.setResponseHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(file.getReadLength()));
        } else {
            response.setChunked(true);
        }
        file.handler(buffer -> {
            try {
                response.write(buffer.getBytes());
            } catch (Exception x) {
                
                ctx.resume(x);
                return;
            }
            if (response.isWriteQueueFull()) {
                file.pause();
                response.addDrainHandler(new Runnable() {
                    @Override
                    public void run() {
                        file.resume();
                    }
                });
            }
        });

        file.endHandler(new Handler<Void>() {
            @Override
            public void handle(Void event) {
                file.close();
                response.end();
                
                ctx.resume();
            }
        });
    }
Code review comment: It's true, though! 😬  But I'll remove it.

Code under review:
OperationHandlerImpl createHandler() throws Exception {
            VisitorSession visitorSession = mock(VisitorSession.class);
            
            when(documentAccess.createVisitorSession(any(VisitorParameters.class))).thenAnswer(p -> {
                
                VisitorParameters params = (VisitorParameters)p.getArguments()[0];
                assignedParameters.set(params);

                VisitorStatistics statistics = new VisitorStatistics();
                statistics.setBucketsVisited(bucketsVisited);
                params.getControlHandler().onVisitorStatistics(statistics);

                ProgressToken progress = new ProgressToken();
                params.getControlHandler().onProgress(progress);

                params.getControlHandler().onDone(completionCode, "bork bork");
                return visitorSession;
            });
            OperationHandlerImpl.ClusterEnumerator clusterEnumerator = () -> Arrays.asList(new ClusterDef("foo", "configId"));
            return new OperationHandlerImpl(documentAccess, clusterEnumerator);
        }


Revised code:
OperationHandlerImpl createHandler() throws Exception {
            VisitorSession visitorSession = mock(VisitorSession.class);
            
            when(documentAccess.createVisitorSession(any(VisitorParameters.class))).thenAnswer(p -> {
                VisitorParameters params = (VisitorParameters)p.getArguments()[0];
                assignedParameters.set(params);

                VisitorStatistics statistics = new VisitorStatistics();
                statistics.setBucketsVisited(bucketsVisited);
                params.getControlHandler().onVisitorStatistics(statistics);

                ProgressToken progress = new ProgressToken();
                params.getControlHandler().onProgress(progress);

                params.getControlHandler().onDone(completionCode, "bork bork");
                return visitorSession;
            });
            OperationHandlerImpl.ClusterEnumerator clusterEnumerator = () -> Arrays.asList(new ClusterDef("foo", "configId"));
            return new OperationHandlerImpl(documentAccess, clusterEnumerator);
        }
Code review comment: Created issue #31678 to track above.

Code under review:
public static Optional<Symbol> getDocumentableSymbol(NonTerminalNode node, SemanticModel semanticModel) {
        switch (node.kind()) {
            case FUNCTION_DEFINITION:
            case OBJECT_METHOD_DEFINITION:
            case RESOURCE_ACCESSOR_DEFINITION:
            case METHOD_DECLARATION:
            case SERVICE_DECLARATION:    





            case TYPE_DEFINITION:
            case CLASS_DEFINITION:
                return semanticModel.symbol(node);
            default:
                break;
        }
        return Optional.empty();
    }


Revised code:
public static Optional<Symbol> getDocumentableSymbol(NonTerminalNode node, SemanticModel semanticModel) {
        switch (node.kind()) {
            case FUNCTION_DEFINITION:
            case OBJECT_METHOD_DEFINITION:
            case RESOURCE_ACCESSOR_DEFINITION:
            case METHOD_DECLARATION:
            case SERVICE_DECLARATION:    





            case TYPE_DEFINITION:
            case CLASS_DEFINITION:
                return semanticModel.symbol(node);
            default:
                break;
        }
        return Optional.empty();
    }
Code review comment: http and Listener should move to constants.

Code under review:
void invokeFilters(BLangResource resourceNode, SymbolEnv env) {
        if (resourceNode.requiredParams.size() == 2 && "http".equals(resourceNode.requiredParams.get(
                0).type.tsymbol.pkgID.name.value) && "Listener".equals(resourceNode.requiredParams.get(
                0).type.tsymbol.name.value)) {
            addFilterStatements(resourceNode, env);
        }
    }

Line commented on: if (resourceNode.requiredParams.size() == 2 && "http".equals(resourceNode.requiredParams.get(

Revised code:
void invokeFilters(BLangResource resourceNode, SymbolEnv env) {
        BLangVariable endpoint;
        if (resourceNode.requiredParams.size() == 2) {
            endpoint = resourceNode.requiredParams.get(0);
            if (ORG_NAME.equals(endpoint.type.tsymbol.pkgID.orgName.value) && PACKAGE_NAME.equals(
                    endpoint.type.tsymbol.pkgID.name.value) && ENDPOINT_TYPE_NAME.equals(
                    endpoint.type.tsymbol.name.value)) {
                addFilterStatements(resourceNode, env);
            }
        }
    }
Code review comment: In the current state of the PR, `-r` is no longer valid.

Code under review:
public void testClaimRestoreModeParsing() throws Exception {
        
        String[] parameters = {
            "-s", "expectedSavepointPath", "-n", "-r", "claim", getTestJarPath()
        };

        CommandLine commandLine =
                CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
        ProgramOptions programOptions = ProgramOptions.create(commandLine);
        ExecutionConfigAccessor executionOptions =
                ExecutionConfigAccessor.fromProgramOptions(programOptions, Collections.emptyList());

        SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
        assertTrue(savepointSettings.restoreSavepoint());
        assertEquals(RestoreMode.CLAIM, savepointSettings.getRestoreMode());
        assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
        assertTrue(savepointSettings.allowNonRestoredState());
    }

Line commented on: "-s", "expectedSavepointPath", "-n", "-r", "claim", getTestJarPath()

Revised code:
public void testClaimRestoreModeParsing() throws Exception {
        
        String[] parameters = {
            "-s", "expectedSavepointPath", "-n", "-restoreMode", "claim", getTestJarPath()
        };

        CommandLine commandLine =
                CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
        ProgramOptions programOptions = ProgramOptions.create(commandLine);
        ExecutionConfigAccessor executionOptions =
                ExecutionConfigAccessor.fromProgramOptions(programOptions, Collections.emptyList());

        SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
        assertTrue(savepointSettings.restoreSavepoint());
        assertEquals(RestoreMode.CLAIM, savepointSettings.getRestoreMode());
        assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
        assertTrue(savepointSettings.allowNonRestoredState());
    }
Code review comment: Why do we need to call clear here?

Code under review:
public void init() throws IOException {
		resultPath = tempFolder().newFolder().toURI().toString();
		clear();

		env().setParallelism(3);
		env().enableCheckpointing(100);

		rows = new ArrayList<>();
		for (int i = 0; i < 100; i++) {
			rows.add(Row.of(i, String.valueOf(i % 10), String.valueOf(i)));
		}

		DataStream<Row> stream = new DataStream<>(env().getJavaEnv().addSource(
				new ParallelFiniteTestSource<>(rows),
				new RowTypeInfo(
						new TypeInformation[] {Types.INT, Types.STRING, Types.STRING},
						new String[] {"a", "b", "c"})));

		tEnv().createTemporaryView("my_table",  stream);
	}

Line commented on: clear();

Revised code:
public void init() throws IOException {
		resultPath = tempFolder().newFolder().toURI().toString();

		env().setParallelism(3);
		env().enableCheckpointing(100);

		List<Row> rows = new ArrayList<>();
		for (int i = 0; i < 100; i++) {
			rows.add(Row.of(i, String.valueOf(i % 10), String.valueOf(i)));
		}

		this.expectedRows = new ArrayList<>();
		this.expectedRows.addAll(rows);
		this.expectedRows.addAll(rows);
		this.expectedRows.sort(Comparator.comparingInt(o -> (Integer) o.getField(0)));

		DataStream<Row> stream = new DataStream<>(env().getJavaEnv().addSource(
				new ParallelFiniteTestSource<>(rows),
				new RowTypeInfo(
						new TypeInformation[] {Types.INT, Types.STRING, Types.STRING},
						new String[] {"a", "b", "c"})));

		tEnv().createTemporaryView("my_table",  stream);
	}
Code review comment: how about :  ```         assertThat(configuration.keySet()).containsExactly(expectedKey); ```

Code under review:
void testDelegationConfigurationWithPrefix() {
        String prefix = "pref-";
        String expectedKey = "key";

        /*
         * Key matches the prefix
         */
        Configuration backingConf = new Configuration();
        backingConf.setValueInternal(prefix + expectedKey, "value", false);

        DelegatingConfiguration configuration = new DelegatingConfiguration(backingConf, prefix);
        Set<String> keySet = configuration.keySet();

        assertThat(keySet).hasSize(1);
        assertThat(expectedKey).isEqualTo(keySet.iterator().next());

        /*
         * Key does not match the prefix
         */
        backingConf = new Configuration();
        backingConf.setValueInternal("test-key", "value", false);

        configuration = new DelegatingConfiguration(backingConf, prefix);
        keySet = configuration.keySet();

        assertThat(keySet).isEmpty();
    }

Line commented on: assertThat(expectedKey).isEqualTo(keySet.iterator().next());

Revised code:
void testDelegationConfigurationWithPrefix() {
        String prefix = "pref-";
        String expectedKey = "key";

        /*
         * Key matches the prefix
         */
        Configuration backingConf = new Configuration();
        backingConf.setValueInternal(prefix + expectedKey, "value", false);

        DelegatingConfiguration configuration = new DelegatingConfiguration(backingConf, prefix);
        Set<String> keySet = configuration.keySet();
        assertThat(keySet).hasSize(1).containsExactly(expectedKey);

        /*
         * Key does not match the prefix
         */
        backingConf = new Configuration();
        backingConf.setValueInternal("test-key", "value", false);

        configuration = new DelegatingConfiguration(backingConf, prefix);
        assertThat(configuration.keySet()).isEmpty();
    }
Code review comment: It's better to use AdminClient rather KafkaConsumer if we only want to get topic meatdata.

Code under review:
private void tryDelete(AdminClient adminClient, String topic) throws Exception {
        try {
            adminClient
                    .deleteTopics(Collections.singleton(topic))
                    .all()
                    .get(DELETE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
            try (KafkaConsumer<Void, Void> consumer = createTempConsumer()) {
                CommonTestUtils.waitUtil(
                        () -> {
                            List<PartitionInfo> partitionInfos = consumer.partitionsFor(topic);
                            return partitionInfos == null || partitionInfos.isEmpty();
                        },
                        Duration.ofSeconds(DELETE_TIMEOUT_SECONDS),
                        String.format("Topic \"%s\" was not deleted within timeout", topic));
            }
        } catch (TimeoutException e) {
            LOG.info(
                    "Did not receive delete topic response within {} seconds. Checking if it succeeded",
                    DELETE_TIMEOUT_SECONDS);
            if (adminClient
                    .listTopics()
                    .names()
                    .get(DELETE_TIMEOUT_SECONDS, TimeUnit.SECONDS)
                    .contains(topic)) {
                throw new Exception("Topic still exists after timeout", e);
            }
        }
    }

Line commented on: try (KafkaConsumer<Void, Void> consumer = createTempConsumer()) {

Revised code:
private void tryDelete(AdminClient adminClient, String topic) throws Exception {
        try {
            adminClient
                    .deleteTopics(Collections.singleton(topic))
                    .all()
                    .get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
            CommonTestUtils.waitUtil(
                    () -> {
                        try {
                            return adminClient.listTopics().listings()
                                    .get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS).stream()
                                    .map(TopicListing::name)
                                    .noneMatch((name) -> name.equals(topic));
                        } catch (Exception e) {
                            LOG.warn("Exception caught when listing Kafka topics", e);
                            return false;
                        }
                    },
                    Duration.ofSeconds(REQUEST_TIMEOUT_SECONDS),
                    String.format("Topic \"%s\" was not deleted within timeout", topic));
        } catch (TimeoutException e) {
            LOG.info(
                    "Did not receive delete topic response within {} seconds. Checking if it succeeded",
                    REQUEST_TIMEOUT_SECONDS);
            if (adminClient
                    .listTopics()
                    .names()
                    .get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS)
                    .contains(topic)) {
                throw new Exception("Topic still exists after timeout", e);
            }
        }
    }