muttakin2301/ccr2000 huggingface dataset:
Code review comment: What is the argument for changing the default approach for a more knob based one ? Maybe is better to preserve the default and only overwrite it if this is parametrized.

Code under review:
public Partition[] getPartitions() {
      try {
        List<? extends Source<T>> partitionedSources = source.split(bundleSize, options.get());
        Partition[] partitions = new SourcePartition[partitionedSources.size()];
        for (int i = 0; i < partitionedSources.size(); i++) {
          partitions[i] = new SourcePartition<>(id(), i, partitionedSources.get(i));
        }
        return partitions;
      } catch (Exception e) {
        throw new RuntimeException(
            "Failed to create partitions for source " + source.getClass().getSimpleName(), e);
      }
    }

Line commented on: List<? extends Source<T>> partitionedSources = source.split(bundleSize, options.get());

Revised code:
public Partition[] getPartitions() {
      try {
        List<? extends Source<T>> partitionedSources;
        if (bundleSize > 0) {
          partitionedSources = source.split(bundleSize, options.get());
        } else {
          long desiredSizeBytes = DEFAULT_BUNDLE_SIZE;
          try {
            desiredSizeBytes = source.getEstimatedSizeBytes(options.get()) / numPartitions;
          } catch (Exception e) {
            LOG.warn(
                "Failed to get estimated bundle size for source {}, using default bundle "
                    + "size of {} bytes.",
                source,
                DEFAULT_BUNDLE_SIZE);
          }
          partitionedSources = source.split(desiredSizeBytes, options.get());
        }
        Partition[] partitions = new SourcePartition[partitionedSources.size()];
        for (int i = 0; i < partitionedSources.size(); i++) {
          partitions[i] = new SourcePartition<>(id(), i, partitionedSources.get(i));
        }
        return partitions;
      } catch (Exception e) {
        throw new RuntimeException(
            "Failed to create partitions for source " + source.getClass().getSimpleName(), e);
      }
    }
Code review comment: @tiagobento could you please explain this one. `ignoreAvailability` is `true`. Is it availability of artifacts that should be ignored?

Code under review:
public void testValidTailFromRemoteIgnoringAvailabilityViaSystemPropBlank() throws Exception {
        setSystemProp("maven.repo.local.tail.ignoreAvailability", " "); 
        final BootstrapMavenContext mvn = bootstrapMavenContextForProject("workspace-with-local-repo-tail",
                BootstrapMavenContext.config()
                        .setLocalRepositoryTail(new String[] { M2_FROM_REMOTE }));

        assertNotNull(resolveOrgAcmeFooJar001(mvn));
    }

Line commented on: assertNotNull(resolveOrgAcmeFooJar001(mvn));

Revised code:
public void testValidTailFromRemoteIgnoringAvailabilityViaSystemPropBlank() throws Exception {
        setSystemProp("maven.repo.local.tail.ignoreAvailability", " "); 
        final BootstrapMavenContext mvn = bootstrapMavenContextForProject("workspace-with-local-repo-tail",
                BootstrapMavenContext.config()
                        .setLocalRepositoryTail(new String[] { M2_FROM_REMOTE }));

        assertNotNull(resolveOrgAcmeFooJar001(mvn));
    }
Code review comment: missing a check for it failing if only the port is set.

Code under review:
public void testConnectToPushGatewayThrowsExceptionWithoutHostInformation() {
        PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
        MetricConfig metricConfig = new MetricConfig();
        Assert.assertThrows(
                IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));

        metricConfig.setProperty(HOST.key(), "localhost");
        Assert.assertThrows(
                IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));
    }

Line commented on: IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));

Revised code:
public void testConnectToPushGatewayThrowsExceptionWithoutHostInformation() {
        PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
        MetricConfig metricConfig = new MetricConfig();
        Assert.assertThrows(
                IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));

        metricConfig.setProperty(HOST.key(), "localhost");
        Assert.assertThrows(
                IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));

        metricConfig.clear();
        metricConfig.setProperty(PORT.key(), "18080");
        Assert.assertThrows(
                IllegalArgumentException.class, () -> factory.createMetricReporter(metricConfig));
    }
Code review comment: I agree. I think we can change the error msg like: ``` data cannot be inserted into table with emtpy partition... Use `SHOW PARTITIONS FROM tbl` to see the currenty partitions of this table.  ```  And also change the msg in error code `ERR_EMPTY_PARTITION_IN_TABLE`

Code under review:
private List<Long> getAllPartitionIds() throws LoadException, MetaNotFoundException {
        Set<Long> partitionIds = Sets.newHashSet();
        for (BrokerFileGroup brokerFileGroup : fileGroups) {
            if (brokerFileGroup.getPartitionIds() != null) {
                partitionIds.addAll(brokerFileGroup.getPartitionIds());
            }
            
            
            break;
        }

        if (partitionIds.isEmpty()) {
            for (Partition partition : table.getPartitions()) {
                partitionIds.add(partition.getId());
            }
        }

        
        
        if (partitionIds.isEmpty()) {
            throw new LoadException("data cannot be inserted into table with emtpy partition. " +
                    "[" + table.getName() + "]");
        }

        return Lists.newArrayList(partitionIds);
    }

Line commented on: throw new LoadException("data cannot be inserted into table with emtpy partition. " +

Revised code:
private List<Long> getAllPartitionIds() throws LoadException, MetaNotFoundException {
        Set<Long> partitionIds = Sets.newHashSet();
        for (BrokerFileGroup brokerFileGroup : fileGroups) {
            if (brokerFileGroup.getPartitionIds() != null) {
                partitionIds.addAll(brokerFileGroup.getPartitionIds());
            }
            
            
            break;
        }

        if (partitionIds.isEmpty()) {
            for (Partition partition : table.getPartitions()) {
                partitionIds.add(partition.getId());
            }
        }

        
        
        if (partitionIds.isEmpty()) {
            throw new LoadException("data cannot be inserted into table with empty partition. " +
                    "Use `SHOW PARTITIONS FROM " + table.getName() + "` to see the currently partitions of this table. ");
        }

        return Lists.newArrayList(partitionIds);
    }
Code review comment: The request will likely fail (usually nothing is running on 8080), but the result is ignored, so it won't affect the test.

Code under review:
public void testInterruptsNotCached() throws Exception {
		ConnectionID connectionId = new ConnectionID(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 0);
		AwaitingNettyClient nettyClient = new AwaitingNettyClient();
		PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0);

		nettyClient.awaitForInterrupts = true;
		connectAndInterrupt(factory, connectionId);

		nettyClient.awaitForInterrupts = false;
		factory.createPartitionRequestClient(connectionId);
	}

Line commented on: ConnectionID connectionId = new ConnectionID(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 0);

Revised code:
public void testInterruptsNotCached() throws Exception {
		ConnectionID connectionId = new ConnectionID(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 0);
		try (AwaitingNettyClient nettyClient = new AwaitingNettyClient()) {
			PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0);

			nettyClient.awaitForInterrupts = true;
			connectAndInterrupt(factory, connectionId);

			nettyClient.awaitForInterrupts = false;
			factory.createPartitionRequestClient(connectionId);
		}
	}
Code review comment: Unfortunately, we cannot directly obtain the information about whether slot desc is nullable or not from Expr.

Code under review:
public TupleDescriptor createTupleDescriptor(Analyzer analyzer) throws AnalysisException {
        
        int numColLabels = getColLabels().size();
        Preconditions.checkState(numColLabels > 0);
        Set<String> columnSet = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
        List<Column> columnList = Lists.newArrayList();
        for (int i = 0; i < numColLabels; ++i) {
            
            Expr selectItemExpr = queryStmt.getResultExprs().get(i);
            
            String colAlias = getColLabels().get(i);

            
            if (columnSet.contains(colAlias)) {
                throw new AnalysisException(
                        "Duplicated inline view column alias: '" + colAlias + "'" + " in inline view "
                                + "'" + getAlias() + "'");
            }

            columnSet.add(colAlias);
            
            
            columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(), true));
        }
        InlineView inlineView = (view != null) ? new InlineView(view, columnList) : new InlineView(getExplicitAlias(), columnList);

        
        TupleDescriptor result = analyzer.getDescTbl().createTupleDescriptor();
        result.setIsMaterialized(false);
        result.setTable(inlineView);
        return result;
    }

Line commented on: columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(), true));

Revised code:
public TupleDescriptor createTupleDescriptor(Analyzer analyzer) throws AnalysisException {
        
        int numColLabels = getColLabels().size();
        Preconditions.checkState(numColLabels > 0);
        Set<String> columnSet = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
        List<Column> columnList = Lists.newArrayList();
        for (int i = 0; i < numColLabels; ++i) {
            
            Expr selectItemExpr = queryStmt.getResultExprs().get(i);
            
            String colAlias = getColLabels().get(i);

            
            if (columnSet.contains(colAlias)) {
                throw new AnalysisException(
                        "Duplicated inline view column alias: '" + colAlias + "'" + " in inline view "
                                + "'" + getAlias() + "'");
            }

            columnSet.add(colAlias);
            
            
            columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(), true));
        }
        InlineView inlineView = (view != null) ? new InlineView(view, columnList) : new InlineView(getExplicitAlias(), columnList);

        
        TupleDescriptor result = analyzer.getDescTbl().createTupleDescriptor();
        result.setIsMaterialized(false);
        result.setTable(inlineView);
        return result;
    }
Code review comment: u r right, UT and regression test not be processed now

Code under review:
public static LogicalPlanAdapter of(Plan plan) {
        return new LogicalPlanAdapter((LogicalPlan) plan, null);
    }

Line commented on: return new LogicalPlanAdapter((LogicalPlan) plan, null);

Revised code:
public static LogicalPlanAdapter of(Plan plan) {
        return new LogicalPlanAdapter((LogicalPlan) plan, null);
    }
Code review comment: Let's trying to using the `org.hamcrest.MatcherAssert.assertThat` in the new introduced test.

Code under review:
public void testServiceClassify() {
        Assert.assertEquals(
                KubernetesConfigOptions.ServiceExposedType.ClusterIP,
                ServiceType.classify(buildExternalServiceWithClusterIP()));
        Assert.assertEquals(
                KubernetesConfigOptions.ServiceExposedType.Headless_ClusterIP,
                ServiceType.classify(buildExternalServiceWithHeadlessClusterIP()));
        Assert.assertEquals(
                KubernetesConfigOptions.ServiceExposedType.NodePort,
                ServiceType.classify(buildExternalServiceWithNodePort()));
        Assert.assertEquals(
                KubernetesConfigOptions.ServiceExposedType.LoadBalancer,
                ServiceType.classify(buildExternalServiceWithLoadBalancer("", "")));
    }

Line commented on: Assert.assertEquals(

Revised code:
public void testServiceClassify() {
        assertThat(
                ServiceType.classify(buildExternalServiceWithClusterIP()),
                is(KubernetesConfigOptions.ServiceExposedType.ClusterIP));
        assertThat(
                ServiceType.classify(buildExternalServiceWithHeadlessClusterIP()),
                is(KubernetesConfigOptions.ServiceExposedType.Headless_ClusterIP));
        assertThat(
                ServiceType.classify(buildExternalServiceWithNodePort()),
                is(KubernetesConfigOptions.ServiceExposedType.NodePort));
        assertThat(
                ServiceType.classify(buildExternalServiceWithLoadBalancer("", "")),
                is(KubernetesConfigOptions.ServiceExposedType.LoadBalancer));
    }
Code review comment: Should we add a more descriptive log message here? There is no `toString` implementation for `DefaultMultipleComponentLeaderElectionService` for now. Or is the memory address of the instance good enough? 🤔

Code under review:
public void close() throws Exception {
        synchronized (lock) {
            if (!running) {
                return;
            }
            running = false;

            LOG.info("Closing {}.", this);

            ExecutorUtils.gracefulShutdown(10L, TimeUnit.SECONDS, leadershipOperationExecutor);

            Exception exception = null;
            try {
                multipleComponentLeaderElectionDriver.close();
            } catch (Exception e) {
                exception = e;
            }

            ExceptionUtils.tryRethrowException(exception);
        }
    }

Line commented on: LOG.info("Closing {}.", this);

Revised code:
public void close() throws Exception {
        synchronized (lock) {
            if (!running) {
                return;
            }
            running = false;

            LOG.info("Closing {}.", this.getClass().getSimpleName());

            ExecutorUtils.gracefulShutdown(10L, TimeUnit.SECONDS, leadershipOperationExecutor);

            multipleComponentLeaderElectionDriver.close();
        }
    }
Code review comment: Two questions:  1. Should we not ignore the exception? Just in case of some unexpected exceptions/bugs/problems? I guess the expected exception is `InterruptedException`? 2. Shouldn't this be in a `while (true)` loop with ignoring interruptions?

Code under review:
protected void afterInvoke() throws Exception {
		LOG.debug("Finished task {}", getName());
		getCompletionFuture().exceptionally(unused -> null).join();

		final CompletableFuture<Void> timersFinishedFuture = new CompletableFuture<>();

		
		operatorChain.closeOperators(actionExecutor);

		
		
		actionExecutor.runThrowing(() -> {

			
			FutureUtils.forward(timerService.quiesce(), timersFinishedFuture);

			
			mailboxProcessor.prepareClose();

			
			
			isRunning = false;
		});
		
		mailboxProcessor.drain();

		
		timersFinishedFuture.get();

		LOG.debug("Closed operators for task {}", getName());

		
		operatorChain.flushOutputs();

		
		
		disposeAllOperators();
	}

Line commented on: getCompletionFuture().exceptionally(unused -> null).join();

Revised code:
protected void afterInvoke() throws Exception {
		LOG.debug("Finished task {}", getName());
		getCompletionFuture().exceptionally(unused -> null).join();

		final CompletableFuture<Void> timersFinishedFuture = new CompletableFuture<>();

		
		operatorChain.closeOperators(actionExecutor);

		
		
		actionExecutor.runThrowing(() -> {

			
			FutureUtils.forward(timerService.quiesce(), timersFinishedFuture);

			
			mailboxProcessor.prepareClose();

			
			
			isRunning = false;
		});
		
		mailboxProcessor.drain();

		
		timersFinishedFuture.get();

		LOG.debug("Closed operators for task {}", getName());

		
		operatorChain.flushOutputs();

		
		
		disposeAllOperators();
	}
Code review comment: gsonPostProcess() just ensures its load from json and fill the name if is null. but the constructor and the setName() never promises the name is not null, so there is an implicit rule here that the user who uses this class should never provide null value or setName(null), otherwise NPE may occur.  Is it possible to remove this implicit rule by converting the null to "" for every possible interface? that's the fundamental benefit from a OOP language.

Code under review:
public PhysicalPartitionImpl(long id, String name, long parentId, long sharedGroupId, MaterializedIndex baseIndex) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.baseIndex = baseIndex;
        this.visibleVersion = PARTITION_INIT_VERSION;
        this.visibleVersionTime = System.currentTimeMillis();
        this.nextVersion = PARTITION_INIT_VERSION + 1;
        this.shardGroupId = sharedGroupId;
    }

Line commented on: this.name = name;

Revised code:
public PhysicalPartitionImpl(long id, String name, long parentId, long sharedGroupId, MaterializedIndex baseIndex) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.baseIndex = baseIndex;
        this.visibleVersion = PARTITION_INIT_VERSION;
        this.visibleVersionTime = System.currentTimeMillis();
        this.nextVersion = PARTITION_INIT_VERSION + 1;
        this.shardGroupId = sharedGroupId;
    }
Code review comment: ```suggestion     assertThat(options.getCheckpointingMode(), is(CheckpointingMode.EXACTLY_ONCE.name())); ```

Code under review:
public void testDefaults() {
    FlinkPipelineOptions options = PipelineOptionsFactory.as(FlinkPipelineOptions.class);
    assertThat(options.getParallelism(), is(-1));
    assertThat(options.getMaxParallelism(), is(-1));
    assertThat(options.getFlinkMaster(), is("[auto]"));
    assertThat(options.getFilesToStage(), is(nullValue()));
    assertThat(options.getLatencyTrackingInterval(), is(0L));
    assertThat(options.isShutdownSourcesOnFinalWatermark(), is(false));
    assertThat(options.getObjectReuse(), is(false));
    assertThat(options.getCheckpointingMode(), is("EXACTLY_ONCE"));
    assertThat(options.getMinPauseBetweenCheckpoints(), is(-1L));
    assertThat(options.getCheckpointingInterval(), is(-1L));
    assertThat(options.getCheckpointTimeoutMillis(), is(-1L));
    assertThat(options.getFailOnCheckpointingErrors(), is(true));
    assertThat(options.getNumberOfExecutionRetries(), is(-1));
    assertThat(options.getExecutionRetryDelay(), is(-1L));
    assertThat(options.getRetainExternalizedCheckpointsOnCancellation(), is(false));
    assertThat(options.getStateBackend(), is(nullValue()));
    assertThat(options.getMaxBundleSize(), is(1000L));
    assertThat(options.getMaxBundleTimeMills(), is(1000L));
    assertThat(options.getExecutionModeForBatch(), is("PIPELINED"));
    assertThat(options.getSavepointPath(), is(nullValue()));
    assertThat(options.getAllowNonRestoredState(), is(false));
  }

Line commented on: assertThat(options.getCheckpointingMode(), is("EXACTLY_ONCE"));

Revised code:
public void testDefaults() {
    FlinkPipelineOptions options = PipelineOptionsFactory.as(FlinkPipelineOptions.class);
    assertThat(options.getParallelism(), is(-1));
    assertThat(options.getMaxParallelism(), is(-1));
    assertThat(options.getFlinkMaster(), is("[auto]"));
    assertThat(options.getFilesToStage(), is(nullValue()));
    assertThat(options.getLatencyTrackingInterval(), is(0L));
    assertThat(options.isShutdownSourcesOnFinalWatermark(), is(false));
    assertThat(options.getObjectReuse(), is(false));
    assertThat(options.getCheckpointingMode(), is(CheckpointingMode.EXACTLY_ONCE.name()));
    assertThat(options.getMinPauseBetweenCheckpoints(), is(-1L));
    assertThat(options.getCheckpointingInterval(), is(-1L));
    assertThat(options.getCheckpointTimeoutMillis(), is(-1L));
    assertThat(options.getFailOnCheckpointingErrors(), is(true));
    assertThat(options.getNumberOfExecutionRetries(), is(-1));
    assertThat(options.getExecutionRetryDelay(), is(-1L));
    assertThat(options.getRetainExternalizedCheckpointsOnCancellation(), is(false));
    assertThat(options.getStateBackendFactory(), is(nullValue()));
    assertThat(options.getMaxBundleSize(), is(1000L));
    assertThat(options.getMaxBundleTimeMills(), is(1000L));
    assertThat(options.getExecutionModeForBatch(), is(ExecutionMode.PIPELINED.name()));
    assertThat(options.getSavepointPath(), is(nullValue()));
    assertThat(options.getAllowNonRestoredState(), is(false));
  }
Code review comment: use a set, put all supported funtion names into it, check with contain?

Code under review:
public boolean canRewriteAggFunction(ScalarOperator op) {
        if (!(op instanceof CallOperator)) {
            return false;
        }

        CallOperator aggFunc = (CallOperator) op;
        String aggFuncName = aggFunc.getFnName();
        if (aggFuncName.equals(FunctionSet.AVG)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.COUNT) && aggFunc.isDistinct()) {
            return true;
        }
        if (aggFuncName.equals(FunctionSet.BITMAP_UNION_COUNT)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.APPROX_COUNT_DISTINCT) || aggFuncName.equals(FunctionSet.NDV) ||
                aggFuncName.equals(FunctionSet.HLL_UNION_AGG) || aggFuncName.equals(FunctionSet.HLL_CARDINALITY)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.PERCENTILE_APPROX)) {
            return true;
        }
        return false;
    }

Line commented on: if (aggFuncName.equals(FunctionSet.COUNT) && aggFunc.isDistinct()) {

Revised code:
public boolean canRewriteAggFunction(ScalarOperator op) {
        if (!(op instanceof CallOperator)) {
            return false;
        }

        CallOperator aggFunc = (CallOperator) op;
        String aggFuncName = aggFunc.getFnName();
        if (aggFuncName.equals(FunctionSet.AVG)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.COUNT) && aggFunc.isDistinct()) {
            return true;
        }
        if (aggFuncName.equals(FunctionSet.BITMAP_UNION_COUNT)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.APPROX_COUNT_DISTINCT) || aggFuncName.equals(FunctionSet.NDV) ||
                aggFuncName.equals(FunctionSet.HLL_UNION_AGG) || aggFuncName.equals(FunctionSet.HLL_CARDINALITY)) {
            return true;
        }
        
        if (aggFuncName.equals(FunctionSet.PERCENTILE_APPROX)) {
            return true;
        }
        return false;
    }
Code review comment: Why was the judgment of `!stateContext.isPresent()` removed?

Code under review:
public List<MetricFamilySamples> collect() {
        if (!MetricsUtil.isClassExisted(PROXY_CLASS)) {
            return Collections.emptyList();
        }
        Optional<GaugeMetricFamily> proxyInfo = FACTORY.createGaugeMetricFamily(MetricIds.PROXY_INFO);
        if (null == ProxyContext.getInstance().getContextManager() || !proxyInfo.isPresent()) {
            return Collections.emptyList();
        }
        Optional<StateContext> stateContext = ProxyContext.getInstance().getStateContext();
        List<MetricFamilySamples> result = new LinkedList<>();
        proxyInfo.get().addMetric(Collections.singletonList(PROXY_STATE), PROXY_STATE_MAP.get(stateContext.get().getCurrentState()));
        result.add(proxyInfo.get());
        return result;
    }

Line commented on: if (null == ProxyContext.getInstance().getContextManager() || !proxyInfo.isPresent()) {

Revised code:
public List<MetricFamilySamples> collect() {
        if (!MetricsUtil.isClassExisted(PROXY_CLASS) || null == ProxyContext.getInstance().getContextManager()) {
            return Collections.emptyList();
        }
        Optional<GaugeMetricFamily> proxyInfo = FACTORY.createGaugeMetricFamily(MetricIds.PROXY_INFO);
        Optional<StateContext> stateContext = ProxyContext.getInstance().getStateContext();
        if (!proxyInfo.isPresent() || !stateContext.isPresent()) {
            return Collections.emptyList();
        }
        List<MetricFamilySamples> result = new LinkedList<>();
        proxyInfo.get().addMetric(Collections.singletonList(PROXY_STATE), PROXY_STATE_MAP.get(stateContext.get().getCurrentState()));
        result.add(proxyInfo.get());
        return result;
    }
Code review comment: > @xiyelife You could add unit test in `EncryptStatementTest`.  OK, I will.

Code under review:
private String getLogicColumn(final String actualColumn) throws SQLException {
        for (Entry<String, String> entry : logicAndActualColumns.entrySet()) {
            if (entry.getValue().equals(actualColumn)) {
                return entry.getKey();
            }
        }
        throw new SQLException(String.format("Can not get logic column by %s.", actualColumn));
    }

Line commented on: if (entry.getValue().equals(actualColumn)) {

Revised code:
private String getLogicColumn(final String actualColumn) throws SQLException {
        for (Entry<String, String> entry : logicAndActualColumns.entrySet()) {
            if (entry.getValue().equals(actualColumn)) {
                return entry.getKey();
            }
        }
        throw new SQLException(String.format("Can not get logic column by %s.", actualColumn));
    }
Code review comment: Why is this a problem? If the key doesn't exist, we expect a synchronous failure here. And we do assert on the expected exception.

Code under review:
public void getStatusFailsIfKeyUnknown() throws InterruptedException {
        CompletableFuture<OperationResult<String>> statusFuture =
                handler.getSavepointStatus(operationKey);

        assertThat(
                statusFuture,
                futureWillCompleteExceptionally(UnknownOperationKeyException.class, Duration.ZERO));
    }

Line commented on: futureWillCompleteExceptionally(UnknownOperationKeyException.class, Duration.ZERO));

Revised code:
public void getStatusFailsIfKeyUnknown() throws InterruptedException {
        CompletableFuture<OperationResult<String>> statusFuture =
                handler.getSavepointStatus(operationKey);

        assertThat(statusFuture, futureFailedWith(UnknownOperationKeyException.class));
    }
Code review comment: Consider making the other `fail` method call this.

Code under review:
public Node fail(String hostname, boolean keepAllocation, Agent agent, String reason) {
        return move(hostname, keepAllocation, Node.State.failed, agent, Optional.of(reason));
    }

Line commented on: return move(hostname, keepAllocation, Node.State.failed, agent, Optional.of(reason));

Revised code:
public Node fail(String hostname, boolean keepAllocation, Agent agent, String reason) {
        return move(hostname, keepAllocation, Node.State.failed, agent, Optional.of(reason));
    }
Code review comment: The returned Get may be null.

Code under review:
public void eval(Object rowKey) throws IOException {
		
		Result result = table.get(serde.createGet(rowKey));
		if (!result.isEmpty()) {
			
			collect(serde.convertToRow(result));
		}
	}

Line commented on: Result result = table.get(serde.createGet(rowKey));

Revised code:
public void eval(Object rowKey) throws IOException {
		
		Get get = serde.createGet(rowKey);
		if (get != null) {
			Result result = table.get(get);
			if (!result.isEmpty()) {
				
				collect(serde.convertToRow(result));
			}
		}
	}
Code review comment: +1. I'll update the code

Code under review:
public void assertRenewInstanceStatus() {
        StateEvent mockStateEvent = mock(StateEvent.class);
        when(mockStateEvent.getInstanceId()).thenReturn(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId().getId());
        Collection<String> testStates = new LinkedList<>();
        testStates.add(StateType.OK.name());
        testStates.add(StateType.LOCK.name());
        when(mockStateEvent.getStatus()).thenReturn(testStates);
        coordinator.renew(mockStateEvent);
        assertNotNull(contextManager.getInstanceContext());
        assertNotNull(contextManager.getInstanceContext().getInstance());
        assertThat(contextManager.getInstanceContext().getInstance().getStatus(), is(testStates));
        testStates.add(StateType.CIRCUIT_BREAK.name());
        coordinator.renew(mockStateEvent);
        assertThat(contextManager.getInstanceContext().getState().getCurrentState(), is(StateType.CIRCUIT_BREAK));
    }

Line commented on: StateEvent mockStateEvent = mock(StateEvent.class);

Revised code:
public void assertRenewInstanceStatus() {
        Collection<String> testStates = new LinkedList<>();
        testStates.add(StateType.OK.name());
        testStates.add(StateType.LOCK.name());
        StateEvent mockStateEvent = new StateEvent(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId().getId(), testStates);
        coordinator.renew(mockStateEvent);
        assertThat(contextManager.getInstanceContext().getInstance().getStatus(), is(testStates));
        testStates.add(StateType.CIRCUIT_BREAK.name());
        coordinator.renew(mockStateEvent);
        assertThat(contextManager.getInstanceContext().getState().getCurrentState(), is(StateType.CIRCUIT_BREAK));
    }
Code review comment: Since we don't use the `fieldEntry.getKey()` in the loop, we can have something like,  ```java         for (Object value : bMap.values()) {         ...         } ```

Code under review:
public static void validateObjectAssignabilityToBType(Map<String, Object> bMap) {
        for (Map.Entry<String, Object> fieldEntry : bMap.entrySet()) {
            Object value = fieldEntry.getValue();
            if (isInvalidBallerinaValue(value) && !(value instanceof String)) {
                throw ErrorUtils.createJToBTypeCastError(value.getClass());
            }
        }
    }

Line commented on: for (Map.Entry<String, Object> fieldEntry : bMap.entrySet()) {

Revised code:
public static void validateObjectAssignabilityToBType(Map<String, Object> bMap) {
        for (Object value : bMap.values()) {
            if (isInvalidBallerinaValue(value) && !(value instanceof String)) {
                throw ErrorUtils.createJToBTypeCastError(value.getClass());
            }
        }
    }
Code review comment: @alesj Nice catch! And this was the cause ;-). Could you try it again?

Code under review:
static Type resolveTypeParam(Type typeParam, Map<TypeVariable, Type> resolvedTypeParameters, IndexView index) {
        if (typeParam.kind() == Kind.TYPE_VARIABLE) {
            return resolvedTypeParameters.getOrDefault(typeParam, typeParam);
        } else if (typeParam.kind() == Kind.PARAMETERIZED_TYPE) {
            ParameterizedType parameterizedType = typeParam.asParameterizedType();
            ClassInfo classInfo = index.getClassByName(parameterizedType.name());
            if (classInfo != null) {
                List<TypeVariable> typeParameters = classInfo.typeParameters();
                List<Type> arguments = parameterizedType.arguments();
                Map<TypeVariable, Type> resolvedMap = buildResolvedMap(arguments, typeParameters,
                        resolvedTypeParameters, index);
                Type[] typeParams = new Type[typeParameters.size()];
                for (int i = 0; i < typeParameters.size(); i++) {
                    typeParams[i] = resolveTypeParam(arguments.get(i), resolvedMap, index);
                }
                return ParameterizedType.create(parameterizedType.name(), typeParams, null);
            }
        }
        return typeParam;
    }

Line commented on: typeParams[i] = resolveTypeParam(arguments.get(i), resolvedMap, index);

Revised code:
static Type resolveTypeParam(Type typeParam, Map<TypeVariable, Type> resolvedTypeParameters, IndexView index) {
        if (typeParam.kind() == Kind.TYPE_VARIABLE) {
            return resolvedTypeParameters.getOrDefault(typeParam, typeParam);
        } else if (typeParam.kind() == Kind.PARAMETERIZED_TYPE) {
            ParameterizedType parameterizedType = typeParam.asParameterizedType();
            ClassInfo classInfo = index.getClassByName(parameterizedType.name());
            if (classInfo != null) {
                List<TypeVariable> typeParameters = classInfo.typeParameters();
                List<Type> arguments = parameterizedType.arguments();
                Map<TypeVariable, Type> resolvedMap = buildResolvedMap(arguments, typeParameters,
                        resolvedTypeParameters, index);
                Type[] typeParams = new Type[typeParameters.size()];
                for (int i = 0; i < typeParameters.size(); i++) {
                    typeParams[i] = resolveTypeParam(arguments.get(i), resolvedMap, index);
                }
                return ParameterizedType.create(parameterizedType.name(), typeParams, null);
            }
        }
        return typeParam;
    }
Code review comment: I tested and yes, it will only return partitions up to the limit, and the result will be wrong. I will find a way to handle this later.

Code under review:
public List<String> listPartitionNames(String dbName, String tblName) {
        try (CachedClient client = getClient()) {
            return client.client.listPartitionNames(dbName, tblName, MAX_LIST_PARTITION_NUM);
        } catch (Exception e) {
            throw new HMSClientException("failed to list partition names for table %s in db %s", e, tblName, dbName);
        }
    }

Line commented on: return client.client.listPartitionNames(dbName, tblName, MAX_LIST_PARTITION_NUM);

Revised code:
public List<String> listPartitionNames(String dbName, String tblName) {
        try (CachedClient client = getClient()) {
            return client.client.listPartitionNames(dbName, tblName, MAX_LIST_PARTITION_NUM);
        } catch (Exception e) {
            throw new HMSClientException("failed to list partition names for table %s in db %s", e, tblName, dbName);
        }
    }
Code review comment: @ekasumov IMHO this is fine for now just to keep this PR not affecting other code. CORS filter is documented [here](https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/http-reference.adoc). I propose to update `quarkus.http.cors.origins`'s `Description` that `the values starting and ending with `/` are treated as regular expressions`, and copy/paste the example below the table showing reg-ex origins thanks

Code under review:
public static List<Pattern> parseAllowedOriginsRegex(Optional<List<String>> allowedOrigins) {
        if (allowedOrigins == null || !allowedOrigins.isPresent()) {
            return Collections.emptyList();
        }

        
        List<Pattern> allowOriginsRegex = new ArrayList<>();
        allowedOrigins.get().stream()
                .forEach(o -> {
                    if (o != null && o.startsWith("/") && o.endsWith("/")) {
                        allowOriginsRegex.add(Pattern.compile(o.substring(1, o.length() - 1)));
                    }
                });
        return allowOriginsRegex;
    }

Line commented on: allowedOrigins.get().stream()

Revised code:
public static List<Pattern> parseAllowedOriginsRegex(Optional<List<String>> allowedOrigins) {
        if (allowedOrigins == null || !allowedOrigins.isPresent()) {
            return Collections.emptyList();
        }

        
        List<Pattern> allowOriginsRegex = new ArrayList<>();
        for (String o : allowedOrigins.get()) {
            if (o != null && o.startsWith("/") && o.endsWith("/")) {
                allowOriginsRegex.add(Pattern.compile(o.substring(1, o.length() - 1)));
            }
        }

        return allowOriginsRegex;
    }
Code review comment: Actually, we should probably use `@DisabledOnNativeImage` instead. (and maybe explain why with a comment)

Code under review:
public void testInjection() {
        Assumptions.assumeFalse(getClass().isAnnotationPresent(NativeImageTest.class));
        Assert.assertTrue(checkks.call().getState() == HealthCheckResponse.State.UP);
    }

Line commented on: Assert.assertTrue(checkks.call().getState() == HealthCheckResponse.State.UP);

Revised code:
public void testInjection() {
        Assert.assertTrue(simpleHealthCheck.call().getState() == HealthCheckResponse.State.UP);
    }
Code review comment: Yeh sorry I was referring to exit code

Code under review:
public void testNonExistingFunctionExecution() throws BallerinaTestException {
        String msg = "No tests found";
        LogLeecher clientLeecher = new LogLeecher(msg);
        balClient.runMain("test", new String[]{"--functions", "nonExistingFunc", "--all"},
                null, new String[]{}, new LogLeecher[]{clientLeecher}, projectPath);
        clientLeecher.waitForText(20000);
    }

Line commented on: clientLeecher.waitForText(20000);

Revised code:
public void testNonExistingFunctionExecution() throws BallerinaTestException {
        String msg = "No tests found with the given name/s";
        LogLeecher clientLeecher = new LogLeecher(msg);
        balClient.runMain("test", new String[]{"--tests", "nonExistingFunc", "single-test-execution.bal"},
                null, new String[]{}, new LogLeecher[]{clientLeecher}, projectPath);
        clientLeecher.waitForText(20000);
    }
Code review comment: I think it will be much more readable if we handle the else part as well. WDYT?

Code under review:
public void execute(Context context) {
        @SuppressWarnings(ArtemisConstants.UNCHECKED)
        BMap<String, BValue> messageObj = (BMap<String, BValue>) context.getRefArgument(0);
        ClientMessage message = (ClientMessage) messageObj.getNativeData(ArtemisConstants.ARTEMIS_MESSAGE);

        String key = context.getStringArgument(0);
        Object property = message.getObjectProperty(key);
        if (property != null) {
            context.setReturnValues(ArtemisUtils.getBValueFromObj(property, context));
        }
    }

Line commented on: if (property != null) {

Revised code:
public void execute(Context context) {
        @SuppressWarnings(ArtemisConstants.UNCHECKED)
        BMap<String, BValue> messageObj = (BMap<String, BValue>) context.getRefArgument(0);
        ClientMessage message = (ClientMessage) messageObj.getNativeData(ArtemisConstants.ARTEMIS_MESSAGE);

        String key = context.getStringArgument(0);
        Object property = message.getObjectProperty(key);
        if (property != null) {
            context.setReturnValues(ArtemisUtils.getBValueFromObj(property, context));
        } else {
            context.setReturnValues();
        }
    }
Code review comment: Made use of `try-with-resources` for the buffered reader

Code under review:
private void runCommand(String[] args) throws BallerinaTestException {
        balClient.runMain("test", args, null, new String[]{}, new LogLeecher[]{}, projectPath);

        Gson gson = new Gson();

        try {
            BufferedReader bufferedReader = Files.newBufferedReader(resultsJsonPath, StandardCharsets.UTF_8);
            resultObj = gson.fromJson(bufferedReader, JsonObject.class);
            bufferedReader.close();
        } catch (IOException e) {
            throw new BallerinaTestException("Failed to read test_results.json");
        }

    }

Line commented on: try {

Revised code:
private void runCommand(String[] args) throws BallerinaTestException {
        balClient.runMain("test", args, null, new String[]{}, new LogLeecher[]{}, projectPath);

        Gson gson = new Gson();

        try (BufferedReader bufferedReader = Files.newBufferedReader(resultsJsonPath, StandardCharsets.UTF_8)) {
            resultObj = gson.fromJson(bufferedReader, JsonObject.class);
        } catch (IOException e) {
            throw new BallerinaTestException("Failed to read test_results.json");
        }

    }
Code review comment: This instance may out of your control

Code under review:
public void open() throws Exception {

        dataSource = DataSourceCache.getInstance().getSource(driverLocation);
        if (dataSource == null) {
            
            HikariConfig config = new HikariConfig();
            config.setDriverClassName(scanContext.getDriverClassName());
            config.setJdbcUrl(scanContext.getJdbcURL());
            config.setUsername(scanContext.getUser());
            config.setPassword(scanContext.getPassword());
            config.setMaximumPoolSize(scanContext.getConnectionPoolSize());
            dataSource = new HikariDataSource(config);
            DataSourceCache.getInstance().putIfAbsent(driverLocation, dataSource);
        }

        connection = dataSource.getConnection();
        statement = connection.createStatement();
        statement.setFetchSize(scanContext.getStatementFetchSize());
        statement.execute(scanContext.getSql());
        resultSet = statement.getResultSet();
        resultSetMetaData = resultSet.getMetaData();
        resultColumnClassNames = new ArrayList<>(resultSetMetaData.getColumnCount());
        for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
            resultColumnClassNames.add(resultSetMetaData.getColumnClassName(i));
        }
    }

Line commented on: DataSourceCache.getInstance().putIfAbsent(driverLocation, dataSource);

Revised code:
public void open() throws Exception {

        dataSource = DataSourceCache.getInstance().getSource(driverLocation, () -> {
            HikariConfig config = new HikariConfig();
            config.setDriverClassName(scanContext.getDriverClassName());
            config.setJdbcUrl(scanContext.getJdbcURL());
            config.setUsername(scanContext.getUser());
            config.setPassword(scanContext.getPassword());
            config.setMaximumPoolSize(scanContext.getConnectionPoolSize());
            dataSource = new HikariDataSource(config);
            return dataSource;
        });

        connection = dataSource.getConnection();
        statement = connection.createStatement();
        statement.setFetchSize(scanContext.getStatementFetchSize());
        statement.execute(scanContext.getSql());
        resultSet = statement.getResultSet();
        resultSetMetaData = resultSet.getMetaData();
        resultColumnClassNames = new ArrayList<>(resultSetMetaData.getColumnCount());
        for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
            resultColumnClassNames.add(resultSetMetaData.getColumnClassName(i));
        }
    }
Code review comment: It's included in the log, but we don't want to show it in the response.

Code under review:
public String serialize() {
        var writer = new StringWriter();
        try {
            TextFormat.write004(writer, this);
        } catch (IOException e) {
            log.log(Level.WARNING, "Got exception when rendering metrics:", e);
            throw new PrometheusRenderingException("Could not render metrics. Check the log for details.");
        }
        return writer.toString();
    }

Line commented on: throw new PrometheusRenderingException("Could not render metrics. Check the log for details.");

Revised code:
public String serialize() {
        var writer = new StringWriter();
        try {
            TextFormat.write004(writer, this);
        } catch (IOException e) {
            log.log(Level.WARNING, "Got exception when rendering metrics:", e);
            throw new PrometheusRenderingException("Could not render metrics. Check the log for details.");
        }
        return writer.toString();
    }
Code review comment: so all NullLiteral will return lower case null?

Code under review:
public String getStringValueInFe() {
        return null;
    }

Line commented on: return null;

Revised code:
public String getStringValueInFe() {
        return null;
    }
Code review comment: I've fiixed the remaining issues with **cogroup** in `Fix channel indices in StreamTaskNetworkInput`.  The only failing test currently is **union**. But I commented it out so `UnalignedCheckpointITCase` should run, but shouldn't fail any builds.  I can `@Ignore` it again if you prefer.

Code under review:
private static int getNumBuffers(int parallelism, int numShuffles) {
        int buffersPerSubtask =
                parallelism
                        + 1
                        + 
                        2
                                * BUFFER_PER_CHANNEL
                                * parallelism; 
        
        return buffersPerSubtask * parallelism * numShuffles;
    }

Line commented on: return buffersPerSubtask * parallelism * numShuffles;

Revised code:
private static int getNumBuffers(int parallelism, int numShuffles) {
        int buffersPerSubtask =
                parallelism
                        + 1
                        + 
                        2
                                * BUFFER_PER_CHANNEL
                                * parallelism; 
        
        return buffersPerSubtask * parallelism * numShuffles;
    }
Code review comment: We have https://github.com/ballerina-platform/ballerina-lang/issues/31658 to track covering these visits

Code under review:
public void visit(BLangTupleVarRef varRefExpr) {
        varRefExpr.expressions.forEach(this::acceptNode);
        this.acceptNode((BLangNode) varRefExpr.restParam);
    }

Line commented on: this.acceptNode((BLangNode) varRefExpr.restParam);

Revised code:
public void visit(BLangTupleVarRef varRefExpr) {
        varRefExpr.expressions.forEach(this::acceptNode);
        this.acceptNode((BLangNode) varRefExpr.restParam);
    }
Code review comment: Parameters should be in a different order: expected, actual

Code under review:
public void testSelectFieldOfRecord() {
    Schema f1 = Schema.builder().addInt64Field("f0").build();
    Schema f2 = Schema.builder().addRowField("f1", f1).build();
    Schema f3 = Schema.builder().addRowField("f2", f2).build();

    Row r1 = Row.withSchema(f1).addValue(42L).build(); 
    Row r2 = Row.withSchema(f2).addValue(r1).build(); 
    Row r3 = Row.withSchema(f3).addValue(r2).build(); 

    FieldAccessDescriptor fieldAccessDescriptor =
        FieldAccessDescriptor.withFieldNames("f2.f1").resolve(f3);

    Schema outputSchema = SelectHelpers.getOutputSchema(f3, fieldAccessDescriptor);

    Row out = SelectHelpers.selectRow(r3, fieldAccessDescriptor, r3.getSchema(), outputSchema);

    assertEquals(outputSchema, f2);
    assertEquals(out, r2);
  }

Line commented on: assertEquals(out, r2);

Revised code:
public void testSelectFieldOfRecord() {
    Schema f1 = Schema.builder().addInt64Field("f0").build();
    Schema f2 = Schema.builder().addRowField("f1", f1).build();
    Schema f3 = Schema.builder().addRowField("f2", f2).build();

    Row r1 = Row.withSchema(f1).addValue(42L).build(); 
    Row r2 = Row.withSchema(f2).addValue(r1).build(); 
    Row r3 = Row.withSchema(f3).addValue(r2).build(); 

    FieldAccessDescriptor fieldAccessDescriptor =
        FieldAccessDescriptor.withFieldNames("f2.f1").resolve(f3);

    Schema outputSchema = SelectHelpers.getOutputSchema(f3, fieldAccessDescriptor);

    Row out = SelectHelpers.selectRow(r3, fieldAccessDescriptor, r3.getSchema(), outputSchema);

    assertEquals(f2, outputSchema);
    assertEquals(r2, out);
  }