muttakin2301/ccr2000 huggingface dataset:
Code review comment: we would get a NoSuchElementException if the worker symbol is empty. So shall we check for that

Code under review:
public Optional<TypeSymbol> transform(NamedWorkerDeclarationNode namedWorkerDeclarationNode) {
        Optional<Symbol> symbol = semanticModel.symbol(namedWorkerDeclarationNode);
        WorkerSymbol workerSymbol = (WorkerSymbol) symbol.get();
        return Optional.of(workerSymbol.returnType());
    }

Line commented on: WorkerSymbol workerSymbol = (WorkerSymbol) symbol.get();

Revised code:
public Optional<TypeSymbol> transform(NamedWorkerDeclarationNode namedWorkerDeclarationNode) {
        Optional<Symbol> symbol = semanticModel.symbol(namedWorkerDeclarationNode);
        if (symbol.isPresent()) {
            WorkerSymbol workerSymbol = (WorkerSymbol) symbol.get();
            return Optional.of(workerSymbol.returnType());
        }
        return Optional.empty();
    }
Code review comment: we shouldn't match alias right?

Code under review:
public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        BLangImportPackage that = (BLangImportPackage) o;
        if (pkgNameComps != null ? !pkgNameComps.equals(that.pkgNameComps) :
                that.pkgNameComps != null) {
            return false;
        }

        if (version != null ? !version.equals(that.version) : that.version != null) {
            return false;
        }

        return alias.equals(that.alias);
    }

Line commented on: return alias.equals(that.alias);

Revised code:
public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        BLangImportPackage that = (BLangImportPackage) o;
        if (pkgNameComps != null ? !pkgNameComps.equals(that.pkgNameComps) :
                that.pkgNameComps != null) {
            return false;
        }

        if (version != null ? !version.equals(that.version) : that.version != null) {
            return false;
        }

        return alias.equals(that.alias);
    }
Code review comment: > https://issues.apache.org/jira/browse/FLINK-34235  Assigned to you

Code under review:
protected RelNode doVisit(RelNode node) {
        List<RelHint> oldHints = ((Hintable) node).getHints();
        List<RelHint> oldQueryHints = FlinkHints.getAllQueryHints(oldHints);
        
        if (oldQueryHints.isEmpty()) {
            return super.visitChildren(node);
        }

        final List<RelHint> newHints;
        if (node instanceof BiRel) {
            BiRel biRel = (BiRel) node;
            Optional<String> leftName = extractAliasOrTableName(biRel.getLeft());
            Optional<String> rightName = extractAliasOrTableName(biRel.getRight());
            newHints = validateAndGetNewHintsFromBiRel(leftName, rightName, oldHints);
        } else if (node instanceof SingleRel) {
            SingleRel singleRel = (SingleRel) node;
            Optional<String> tableName = extractAliasOrTableName(singleRel.getInput());
            newHints = validateAndGetNewHintsFromSingleRel(tableName, oldHints);
        } else {
            throw new TableException(
                    String.format(
                            "Unsupported node when resolving query hints: %s",
                            node.getClass().getCanonicalName()));
        }

        RelNode newNode = super.visitChildren(node);
        List<RelHint> mergedHints = mergeQueryHintsIfNecessary(newHints);
        
        return ((Hintable) newNode).withHints(mergedHints);
    }

Line commented on: newHints = validateAndGetNewHintsFromBiRel(leftName, rightName, oldHints);

Revised code:
protected RelNode doVisit(RelNode node) {
        List<RelHint> oldHints = ((Hintable) node).getHints();
        List<RelHint> oldQueryHints = FlinkHints.getAllQueryHints(oldHints);
        
        if (oldQueryHints.isEmpty()) {
            return super.visitChildren(node);
        }

        final List<RelHint> newHints;
        if (node instanceof BiRel) {
            BiRel biRel = (BiRel) node;
            Optional<String> leftName = extractAliasOrTableName(biRel.getLeft());
            Optional<String> rightName = extractAliasOrTableName(biRel.getRight());
            newHints = validateAndGetNewHints(leftName, rightName, oldHints);
        } else if (node instanceof SingleRel) {
            SingleRel singleRel = (SingleRel) node;
            Optional<String> tableName = extractAliasOrTableName(singleRel.getInput());
            newHints = validateAndGetNewHints(tableName, oldHints);
        } else {
            throw new TableException(
                    String.format(
                            "Unsupported node when resolving query hints: %s",
                            node.getClass().getCanonicalName()));
        }

        RelNode newNode = super.visitChildren(node);
        List<RelHint> mergedHints = mergeQueryHintsIfNecessary(newHints);
        
        return ((Hintable) newNode).withHints(mergedHints);
    }
Code review comment: +1 to ignore since this file should be transparent to user

Code under review:
public void save() {
        Path buildFilePath = this.sourceRoot.resolve(TARGET_DIR_NAME).resolve(BUILD_FILE);
        boolean shouldUpdate = this.currentPackage().getResolution().autoUpdate();
        
        if (!buildFilePath.toFile().exists()) {
            
            createBuildFile(buildFilePath);
            writeBuildFile(buildFilePath);
            writeDependencies();
        } else {
            try {
                
                BuildJson buildJson = readBuildJson(buildFilePath);
                
                writeDependencies();
                if (buildJson != null) {
                    
                    if (shouldUpdate) {
                        
                        writeBuildFile(buildFilePath);
                    } else {
                        
                        buildJson.setLastBuildTime(System.currentTimeMillis());
                        ProjectUtils.writeBuildFile(buildFilePath, buildJson);
                    }
                } else {
                    writeBuildFile(buildFilePath);
                }
            } catch (JsonSyntaxException e) {
                throw new ProjectException("Invalid '" + BUILD_FILE + "' file format");
            } catch (IOException e) {
                throw new ProjectException("Failed to read the '" + BUILD_FILE + "' file");
            }
        }
    }

Line commented on: writeDependencies();

Revised code:
public void save() {
        Path buildFilePath = this.sourceRoot.resolve(TARGET_DIR_NAME).resolve(BUILD_FILE);
        boolean shouldUpdate = this.currentPackage().getResolution().autoUpdate();
        

        if (!buildFilePath.toFile().exists()) {
            createBuildFile(buildFilePath);
            writeBuildFile(buildFilePath);
            writeDependencies();
        } else {
            BuildJson buildJson = null;
            try {
                buildJson = readBuildJson(buildFilePath);
            } catch (JsonSyntaxException | IOException e) {
                
            }

            
            writeDependencies();

            
            if (buildJson != null && !shouldUpdate) {
                buildJson.setLastBuildTime(System.currentTimeMillis());
                writeBuildFile(buildFilePath, buildJson);
            } else {
                writeBuildFile(buildFilePath);
            }
        }
    }
Code review comment: Nit: could you add some comments here?

Code under review:
private RexNode convertSqlCallWithDefaultNode(SqlRexContext cx, final SqlCall call) {
        RexNode rexNode = StandardConvertletTable.INSTANCE.convertCall(cx, call);
        if (rexNode instanceof RexCall) {
            List<RexNode> rexNodes = new ArrayList<>(((RexCall) rexNode).operands);
            RelDataType[] defaultTypes =
                    FlinkRexUtil.extractDefaultTypes(call.getOperator(), cx.getTypeFactory());
            for (int i = 0; i < rexNodes.size(); i++) {
                if (rexNodes.get(i).getKind() == SqlKind.DEFAULT && defaultTypes.length > 0) {
                    rexNodes.set(
                            i,
                            ((RexCall) rexNodes.get(i))
                                    .clone(defaultTypes[i], ((RexCall) rexNodes.get(i)).operands));
                }
            }
            return ((RexCall) rexNode).clone(rexNode.getType(), rexNodes);
        }

        return rexNode;
    }

Line commented on: FlinkRexUtil.extractDefaultTypes(call.getOperator(), cx.getTypeFactory());

Revised code:
private RexNode convertSqlCallWithDefaultNode(SqlRexContext cx, final SqlCall call) {
        RexNode rexCall = StandardConvertletTable.INSTANCE.convertCall(cx, call);
        SqlCallBinding sqlCallBinding = new SqlCallBinding(cx.getValidator(), null, call);
        FlinkOperatorBinding flinkOperatorBinding = new FlinkOperatorBinding(sqlCallBinding);
        if (rexCall instanceof RexCall) {
            List<RexNode> operands = new ArrayList<>(((RexCall) rexCall).operands);
            for (int i = 0; i < operands.size(); i++) {
                RexNode rexNode = operands.get(i);
                if (rexNode.getKind() == SqlKind.DEFAULT && rexNode instanceof RexCall) {
                    RelDataType relDataType = flinkOperatorBinding.getOperandType(i);
                    operands.set(
                            i,
                            ((RexCall) rexNode).clone(relDataType, ((RexCall) rexNode).operands));
                }
            }
            return ((RexCall) rexCall).clone(rexCall.getType(), operands);
        }
        return rexCall;
    }
Code review comment: I suggest creating a helper function for this (e.g. applyRankingSettings() / considerApplyRankingSettings()) and use that in deriveAttribute() as well to ensure we handle this the same way in both code paths.

Code under review:
private void deriveAttributeAsArrayType(ImmutableSDField field) {
        if (field.isImportedField()) {
            deriveImportedAttributes(field);
            return;
        }
        Attribute attribute = field.getAttributes().get(field.getName());
        if (attribute != null) {
            Ranking ranking = field.getRanking();
            if (ranking != null && ranking.isFilter()) {
                attribute.setEnableBitVectors(true);
                attribute.setEnableOnlyBitVector(true);
            }
            attributes.put(attribute.getName(), attribute.convertToArray());
        }
    }

Line commented on: Ranking ranking = field.getRanking();

Revised code:
private void deriveAttributeAsArrayType(ImmutableSDField field) {
        if (field.isImportedField()) {
            deriveImportedAttributes(field);
            return;
        }
        Attribute attribute = field.getAttributes().get(field.getName());
        if (attribute != null) {
            applyRanking(field, attribute);
            attributes.put(attribute.getName(), attribute.convertToArray());
        }
    }
Code review comment: R these codecov hits false positives?

Code under review:
public void visit(BLangCollectClause collectClause) {
        if (!PositionUtil.withinRightInclusive(this.linePosition, collectClause.getPosition())) {
            return;
        }
        this.scope = collectClause.env;
        this.acceptNode(collectClause.expression, collectClause.env);
    }

Line commented on: return;

Revised code:
public void visit(BLangCollectClause collectClause) {
        if (!PositionUtil.withinRightInclusive(this.linePosition, collectClause.getPosition())) {
            return;
        }
        this.scope = collectClause.env;
        this.acceptNode(collectClause.expression, collectClause.env);
    }
Code review comment: I think the replace variables will be more in the future, maintian them in two separate list is not good.  Personally, I perfer to have a private static `Map<String, String> REPLACE_VARS` and initialize the map in `setup` method.

Code under review:
private static String getInputFromPath(String sqlPath) throws IOException {
        URL url = CliClientITCase.class.getResource("/" + sqlPath);
        String in = IOUtils.toString(url, StandardCharsets.UTF_8);
        
        return StringUtils.replaceEach(
                in,
                new String[] {"$VAR_PIPELINE_JARS", "$VAR_REST_PORT"},
                new String[] {
                    udfDependency.toString(),
                    miniClusterResource.getClientConfiguration().get(PORT).toString()
                });
    }

Line commented on: miniClusterResource.getClientConfiguration().get(PORT).toString()

Revised code:
private static String getInputFromPath(String sqlPath) throws IOException {
        URL url = CliClientITCase.class.getResource("/" + sqlPath);
        String in = IOUtils.toString(url, StandardCharsets.UTF_8);

        
        String[] keys = replaceVars.keySet().toArray(new String[0]);
        String[] values = Arrays.stream(keys).map(replaceVars::get).toArray(String[]::new);

        return StringUtils.replaceEach(in, keys, values);
    }
Code review comment: `.isBlank()` will capture cases such as "      "(empty spaces) as well. Do we really need this or just would `isEmpty()` is suffcient?

Code under review:
public static ParameterSymbol createBallerinaParameter(BVarSymbol symbol, ParameterKind kind) {
        if (symbol == null) {
            return null;
        }
        String name = symbol.getName().getValue().isBlank() ? null : symbol.getName().getValue();
        TypeSymbol typeDescriptor = TypesFactory.getTypeDescriptor(symbol.getType());
        List<Qualifier> qualifiers = new ArrayList<>();
        if ((symbol.flags & Flags.PUBLIC) == Flags.PUBLIC) {
            qualifiers.add(Qualifier.PUBLIC);
        }
        return new BallerinaParameterSymbol(name, typeDescriptor, qualifiers, kind);
    }

Line commented on: String name = symbol.getName().getValue().isBlank() ? null : symbol.getName().getValue();

Revised code:
public static ParameterSymbol createBallerinaParameter(BVarSymbol symbol, ParameterKind kind) {
        if (symbol == null) {
            return null;
        }
        String name = symbol.getName().getValue().isBlank() ? null : symbol.getName().getValue();
        TypeSymbol typeDescriptor = TypesFactory.getTypeDescriptor(symbol.getType());
        List<Qualifier> qualifiers = new ArrayList<>();
        if ((symbol.flags & Flags.PUBLIC) == Flags.PUBLIC) {
            qualifiers.add(Qualifier.PUBLIC);
        }
        return new BallerinaParameterSymbol(name, typeDescriptor, qualifiers, kind);
    }
Code review comment: I am talking about the parameter. A user can still give a raw `identity`, right?

Code under review:
public void pause(String identity) {
        if (identity == null) {
            LOGGER.warn("Cannot pause - identity is null");
            return;
        }
        for (ScheduledTask task : scheduledTasks) {
            if (identity.equals(task.trigger.id)) {
                task.trigger.running = false;
                return;
            }
        }
    }

Line commented on: if (identity.equals(task.trigger.id)) {

Revised code:
public void pause(String identity) {
        Objects.requireNonNull(identity, "Cannot pause - identity is null");
        if (identity.isEmpty()) {
            LOGGER.warn("Cannot pause - identity is empty");
            return;
        }
        String parsedIdentity = SchedulerUtils.lookUpPropertyValue(identity);
        for (ScheduledTask task : scheduledTasks) {
            if (parsedIdentity.equals(task.trigger.id)) {
                task.trigger.setRunning(false);
                return;
            }
        }
    }
Code review comment: Right now this is ignored, I think unintentionally. :)

Code under review:
void testPeekPollOrder() {
        final int initialCapacity = 4;
        final int testSize = 1000;
        final Comparator<Long> comparator = getTestElementPriorityComparator();
        InternalPriorityQueue<TestElement> priorityQueue = newPriorityQueue(initialCapacity);
        HashSet<TestElement> checkSet = new HashSet<>(testSize);

        insertRandomElements(priorityQueue, checkSet, testSize);

        long lastPriorityValue = getHighestPriorityValueForComparator();
        int lastSize = priorityQueue.size();
        assertThat(lastSize).isEqualTo(testSize);
        TestElement testElement;
        while ((testElement = priorityQueue.peek()) != null) {
            assertThat(priorityQueue.isEmpty()).isFalse();
            assertThat(priorityQueue.size()).isEqualTo(lastSize);
            assertThat(priorityQueue.poll()).isEqualTo(testElement);
            assertThat(checkSet.remove(testElement)).isTrue();
            assertThat(testElement.getPriority()).isGreaterThanOrEqualTo(lastPriorityValue);
            lastPriorityValue = testElement.getPriority();
            --lastSize;
        }

        assertThat(priorityQueue);
        assertThat(priorityQueue.size()).isZero();
        assertThat(checkSet).isEmpty();
    }

Line commented on: assertThat(priorityQueue);

Revised code:
void testPeekPollOrder() {
        final int initialCapacity = 4;
        final int testSize = 1000;
        final Comparator<Long> comparator = getTestElementPriorityComparator();
        InternalPriorityQueue<TestElement> priorityQueue = newPriorityQueue(initialCapacity);
        HashSet<TestElement> checkSet = new HashSet<>(testSize);

        insertRandomElements(priorityQueue, checkSet, testSize);

        long lastPriorityValue = getHighestPriorityValueForComparator();
        int lastSize = priorityQueue.size();
        assertThat(lastSize).isEqualTo(testSize);
        TestElement testElement;
        while ((testElement = priorityQueue.peek()) != null) {
            assertThat(priorityQueue.isEmpty()).isFalse();
            assertThat(priorityQueue.size()).isEqualTo(lastSize);
            assertThat(priorityQueue.poll()).isEqualTo(testElement);
            assertThat(checkSet.remove(testElement)).isTrue();
            assertThat(testElement.getPriority()).isGreaterThanOrEqualTo(lastPriorityValue);
            lastPriorityValue = testElement.getPriority();
            --lastSize;
        }

        assertThat(priorityQueue.isEmpty()).isTrue();
        assertThat(priorityQueue.size()).isZero();
        assertThat(checkSet).isEmpty();
    }
Code review comment: you could loop twice. first, only add max,min, second, add other children names. to avoid  reorderedChildNames.add(0, childName) method ,which will need `System.arraycopy`

Code under review:
private void printChildCounters(String prefix, String counterName, StringBuilder builder) {
        if (childCounterMap.get(counterName) == null) {
            return;
        }
        List<String> childNames = Lists.newArrayList(childCounterMap.get(counterName));

        
        List<String> reorderedChildNames = Lists.newArrayList();
        for (String childName : childNames) {
            if (childName.startsWith(MERGED_INFO_PREFIX_MIN) || childName.startsWith(MERGED_INFO_PREFIX_MAX)) {
                reorderedChildNames.add(0, childName);
            } else {
                reorderedChildNames.add(childName);
            }
        }

        for (String childName : reorderedChildNames) {
            Pair<Counter, String> pair = this.counterMap.get(childName);
            Preconditions.checkState(pair != null);
            builder.append(prefix).append("   - ").append(childName).append(": ")
                    .append(printCounter(pair.first.getValue(), pair.first.getType())).append("\n");
            this.printChildCounters(prefix + "  ", childName, builder);
        }
    }

Line commented on: for (String childName : childNames) {

Revised code:
private void printChildCounters(String prefix, String counterName, StringBuilder builder) {
        if (childCounterMap.get(counterName) == null) {
            return;
        }
        List<String> childNames = Lists.newArrayList(childCounterMap.get(counterName));

        
        List<String> minMaxChildNames = Lists.newArrayListWithCapacity(2);
        List<String> otherChildNames = Lists.newArrayListWithCapacity(childNames.size());
        for (String childName : childNames) {
            if (childName.startsWith(MERGED_INFO_PREFIX_MIN) || childName.startsWith(MERGED_INFO_PREFIX_MAX)) {
                minMaxChildNames.add(childName);
            } else {
                otherChildNames.add(childName);
            }
        }
        List<String> reorderedChildNames = Lists.newArrayListWithCapacity(childNames.size());
        reorderedChildNames.addAll(minMaxChildNames);
        reorderedChildNames.addAll(otherChildNames);

        for (String childName : reorderedChildNames) {
            Pair<Counter, String> pair = this.counterMap.get(childName);
            Preconditions.checkState(pair != null);
            builder.append(prefix).append("   - ").append(childName).append(": ")
                    .append(printCounter(pair.first.getValue(), pair.first.getType())).append("\n");
            this.printChildCounters(prefix + "  ", childName, builder);
        }
    }
Code review comment: Ah yes, you're right. Sorry about the noise.

Code under review:
public CompletionStage<Object> resolve(EvalContext context) {
            String val = context.getBase().toString();
            
            val = codePattern.matcher(val).replaceAll("<code>$2</code>");
            val = linkPattern.matcher(val).replaceAll("<code>$2</code>");
            
            val = val.replace("@see", "<br><strong>@see</strong>").replace("@deprecated",
                    "<br><strong>@deprecated</strong>");
            
            return CompletableFuture.completedFuture(new RawString(val));
        }

Line commented on: val = linkPattern.matcher(val).replaceAll("<code>$2</code>");

Revised code:
public CompletionStage<Object> resolve(EvalContext context) {
            String val = context.getBase().toString();
            
            val = codePattern.matcher(val).replaceAll("<code>$2</code>");
            val = linkPattern.matcher(val).replaceAll("<code>$2</code>");
            
            val = val.replace("@see", "<br><strong>@see</strong>").replace("@deprecated",
                    "<br><strong>@deprecated</strong>");
            
            return CompletableFuture.completedFuture(new RawString(val));
        }
Code review comment: Not ideal, but I did not find a better way to check whether the `generate-code` is actually invoked (without adding gRPC). I could also add the inverse case and check that the message *is* logged, but then again there are already so many test projects and `DevMojoIT` already takes > 10 mins. 🤷‍♂️

Code under review:
public void testThatGenerateCodeGoalIsNotTriggeredIfNotConfigured() throws IOException, MavenInvocationException {
        testDir = initProject("projects/classic-no-generate");
        
        
        runAndCheck(false, "-Dquarkus.generate-code.skip=true");

        assertThat(running.log()).doesNotContain("Skipping Quarkus code generation");
        assertThat(running.log()).contains("Copying 1 resource");       
        assertThat(running.log()).contains("Compiling 2 source files"); 
    }

Line commented on: assertThat(running.log()).doesNotContain("Skipping Quarkus code generation");

Revised code:
public void testThatGenerateCodeGoalIsNotTriggeredIfNotConfigured() throws IOException, MavenInvocationException {
        testDir = initProject("projects/classic-no-generate");
        
        
        runAndCheck(false, "-Dquarkus.generate-code.skip=true");

        assertThat(running.log()).doesNotContain("Skipping Quarkus code generation");
        assertThat(running.log()).contains("Copying 1 resource"); 
        assertThat(running.log()).contains("Compiling 2 source files"); 
    }
Code review comment: Actually I did it and forgot to force push :facepalm:

Code under review:
public static KeyedStateBackend<Long> createKeyedStateBackend(StateBackendType backendType) throws IOException {
		switch (backendType) {
			case HEAP:
				rootDir = prepareDirectory(rootDirName, null);
				return createHeapKeyedStateBackend(rootDir);
			case ROCKSDB:
				rootDir = prepareDirectory(rootDirName, null);
				return createRocksDBKeyedStateBackend(rootDir);
			case SINGLE_KEY:
				try {
					return new SingleKeyStateBackend().createKeyedStateBackend(
						null,
						null,
						null,
						new LongSerializer(),
						0,
						null,
						null,
						null,
						null,
						Collections.emptyList(),
						null
					);
				} catch (Exception e) {
					throw new IOException(e);
				}
			default:
				throw new IllegalArgumentException("Unknown backend type: " + backendType);
		}
	}

Line commented on: return new SingleKeyStateBackend().createKeyedStateBackend(

Revised code:
public static KeyedStateBackend<Long> createKeyedStateBackend(StateBackendType backendType) throws IOException {
		switch (backendType) {
			case HEAP:
				rootDir = prepareDirectory(rootDirName, null);
				return createHeapKeyedStateBackend(rootDir);
			case ROCKSDB:
				rootDir = prepareDirectory(rootDirName, null);
				return createRocksDBKeyedStateBackend(rootDir);
			case BATCH_EXECUTION:
				return createBatchExecutionStateBackend();
			default:
				throw new IllegalArgumentException("Unknown backend type: " + backendType);
		}
	}
Code review comment: You can do this with `@RunWith(Parameterized.class)` as a cleanup.

Code under review:
public void testPortableLogicalTypeSerializeDeserilizeCorrectly() {
      List<Schema.FieldType> testCases =
          ImmutableList.<Schema.FieldType>builder()
              .add(FieldType.logicalType(SqlTypes.DATE))
              .add(FieldType.logicalType(SqlTypes.TIME))
              .add(FieldType.logicalType(SqlTypes.DATETIME))
              .add(FieldType.logicalType(SqlTypes.TIMESTAMP))
              .add(FieldType.logicalType(new NanosInstant()))
              .add(FieldType.logicalType(new NanosDuration()))
              .add(FieldType.logicalType(FixedBytes.of(10)))
              .add(FieldType.logicalType(VariableBytes.of(10)))
              .add(FieldType.logicalType(FixedString.of(10)))
              .add(FieldType.logicalType(VariableString.of(10)))
              .add(FieldType.logicalType(FixedPrecisionNumeric.of(10)))
              .build();

      for (Schema.FieldType fieldType : testCases) {
        SchemaApi.FieldType proto = SchemaTranslation.fieldTypeToProto(fieldType, true);
        Schema.FieldType translated = SchemaTranslation.fieldTypeFromProto(proto);

        assertThat(
            translated.getLogicalType().getClass(), equalTo(fieldType.getLogicalType().getClass()));
        assertThat(
            translated.getLogicalType().getArgumentType(),
            equalTo(fieldType.getLogicalType().getArgumentType()));
        assertThat(
            translated.getLogicalType().getArgument(),
            equalTo(fieldType.getLogicalType().getArgument()));
      }
    }

Line commented on: for (Schema.FieldType fieldType : testCases) {

Revised code:
public void testPortableLogicalTypeSerializeDeserilizeCorrectly() {
      SchemaApi.FieldType proto = SchemaTranslation.fieldTypeToProto(fieldType, true);
      Schema.FieldType translated = SchemaTranslation.fieldTypeFromProto(proto);

      assertThat(
          translated.getLogicalType().getClass(), equalTo(fieldType.getLogicalType().getClass()));
      assertThat(
          translated.getLogicalType().getArgumentType(),
          equalTo(fieldType.getLogicalType().getArgumentType()));
      assertThat(
          translated.getLogicalType().getArgument(),
          equalTo(fieldType.getLogicalType().getArgument()));
    }
Code review comment: I will introduce it in separate PR

Code under review:
public void visit(BLangQueryExpr queryExpr) {
        SymbolEnv prevQueryEnv = this.queryEnv;
        boolean prevWithinQuery = withinQuery;
        
        this.withinQuery = true;
        boolean prevAfterGroupBy = this.afterGroupBy;
        this.afterGroupBy = false;
        queryExpr.getQueryClauses().forEach(this::acceptNode);
        this.withinQuery = prevWithinQuery;
        this.queryEnv = prevQueryEnv;
        this.afterGroupBy = prevAfterGroupBy;
    }

Line commented on: boolean prevAfterGroupBy = this.afterGroupBy;

Revised code:
public void visit(BLangQueryExpr queryExpr) {
        SymbolEnv prevQueryEnv = this.queryEnv;
        boolean prevWithinQuery = withinQuery;
        
        this.withinQuery = true;
        boolean prevAfterGroupBy = this.afterGroupBy;
        this.afterGroupBy = false;
        queryExpr.getQueryClauses().forEach(this::acceptNode);
        this.withinQuery = prevWithinQuery;
        this.queryEnv = prevQueryEnv;
        this.afterGroupBy = prevAfterGroupBy;
    }
Code review comment: Can we wrap using ZstdOutputStream instead of first encoding the entire value to bytes?  Ditto for decoding.

Code under review:
public void encode(T value, OutputStream os) throws IOException {
    ZstdCompressCtx ctx = new ZstdCompressCtx();
    try {
      ctx.setLevel(level);
      ctx.setMagicless(true); 
      ctx.setDictID(false); 
      ctx.loadDict(dict);

      byte[] encoded = CoderUtils.encodeToByteArray(innerCoder, value);
      ctx.setPledgedSrcSize(encoded.length);
      byte[] compressed = ctx.compress(encoded);
      ByteArrayCoder.of().encode(compressed, os);
    } finally {
      ctx.close();
    }
  }

Line commented on: byte[] encoded = CoderUtils.encodeToByteArray(innerCoder, value);

Revised code:
public void encode(T value, OutputStream os) throws IOException {
    ZstdCompressCtx ctx = new ZstdCompressCtx();
    try {
      ctx.setLevel(level);
      ctx.setMagicless(true); 
      ctx.setDictID(false); 
      ctx.loadDict(dict);

      byte[] encoded = CoderUtils.encodeToByteArray(innerCoder, value);
      byte[] compressed = ctx.compress(encoded);
      ByteArrayCoder.of().encode(compressed, os);
    } finally {
      ctx.close();
    }
  }
Code review comment: +1. My impression is that the BQ table naming convention is `project:dataset_name.table_name`? Though I did a quick search and didn't find the exact BQ naming convention.

Code under review:
public static TableReference parseTableUrn(String tableUrn) {
    Matcher match = BigQueryIO.TABLE_URN_SPEC.matcher(tableUrn);
    if (!match.matches()) {
      throw new IllegalArgumentException(
          "Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] "
              + "format: "
              + tableUrn);
    }

    TableReference ref = new TableReference();
    ref.setProjectId(match.group("PROJECT"));

    return ref.setDatasetId(match.group("DATASET")).setTableId(match.group("TABLE"));
  }

Line commented on: "Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] "

Revised code:
public static TableReference parseTableUrn(String tableUrn) {
    Matcher match = BigQueryIO.TABLE_URN_SPEC.matcher(tableUrn);
    if (!match.matches()) {
      throw new IllegalArgumentException(
          "Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] "
              + "format: "
              + tableUrn);
    }

    TableReference ref = new TableReference();
    ref.setProjectId(match.group("PROJECT"));

    return ref.setDatasetId(match.group("DATASET")).setTableId(match.group("TABLE"));
  }
Code review comment: unchecked cast. Is it always `RowTypeInfo`? If so cast it in the constructor.

Code under review:
public Row deserialize(byte[] message) throws IOException {
		try {
			inputStream.setBuffer(message);
			final IndexedRecord read = datumReader.read(record, decoder);
			return convertRecord(schema, (RowTypeInfo) typeInfo, read);
		} catch (Exception e) {
			throw new IOException("Failed to deserialize Avro record.", e);
		}
	}

Line commented on: return convertRecord(schema, (RowTypeInfo) typeInfo, read);

Revised code:
public Row deserialize(byte[] message) throws IOException {
		try {
			inputStream.setBuffer(message);
			record = datumReader.read(record, decoder);
			return convertAvroRecordToRow(schema, typeInfo, record);
		} catch (Exception e) {
			throw new IOException("Failed to deserialize Avro record.", e);
		}
	}
Code review comment: Offline discussion: remove the `relax match` first, deal with it when needed.

Code under review:
public static String defaultApiVersion(String id, Provider provider) {
        if (id == null || provider == null) {
            return null;
        }
        ResourceId resourceId = ResourceId.fromString(id);
        String resourceTypeWithoutNamespace = getFullResourceTypeWithoutNamespace(resourceId);
        
        for (ProviderResourceType prt : provider.resourceTypes()) {
            
            
            if (prt.resourceType().equalsIgnoreCase(resourceTypeWithoutNamespace)) {
                return prt.defaultApiVersion() == null ? prt.apiVersions().get(0) : prt.defaultApiVersion();
            }
        }

        
        String fullResourceType = resourceId.fullResourceType();
        for (ProviderResourceType prt : provider.resourceTypes()) {
            if (fullResourceType.contains(prt.resourceType())) {
                return prt.defaultApiVersion() == null ? prt.apiVersions().get(0) : prt.defaultApiVersion();
            }
        }
        ResourceId parent = resourceId.parent();
        if (parent != null && !CoreUtils.isNullOrEmpty(parent.id())) {
            return defaultApiVersion(parent.id(), provider);
        } else {
            
            return provider.resourceTypes().get(0).apiVersions().get(0);
        }
    }

Line commented on: if (fullResourceType.contains(prt.resourceType())) {

Revised code:
public static String defaultApiVersion(String id, Provider provider) {
        if (id == null || provider == null) {
            return null;
        }
        ResourceId resourceId = ResourceId.fromString(id);
        String resourceTypeWithoutNamespace = getFullResourceTypeWithoutNamespace(resourceId);
        for (ProviderResourceType prt : provider.resourceTypes()) {
            
            
            if (prt.resourceType().equalsIgnoreCase(resourceTypeWithoutNamespace)) {
                return prt.defaultApiVersion() == null ? prt.apiVersions().get(0) : prt.defaultApiVersion();
            }
        }

        ResourceId parent = resourceId.parent();
        if (parent != null && !CoreUtils.isNullOrEmpty(parent.id())) {
            return defaultApiVersion(parent.id(), provider);
        } else {
            
            return provider.resourceTypes().get(0).apiVersions().get(0);
        }
    }
Code review comment: it will print the help information for the protean command

Code under review:
public static void main(String[] args) throws CommandLineParserException {
        CommandRuntime runtime = AeshCommandRuntimeBuilder
                                         .builder()
                                         .commandRegistry(AeshCommandRegistryBuilder.builder().command(ProteanCommand.class).create())
                                         .build();

        if (args.length > 0) {
            StringBuilder sb = new StringBuilder(ProteanCommand.COMMAND_NAME).append(" ");
            if (args.length == 1) {
                sb.append(args[0]);
            } else {
                for (String arg : args) {
                    if (arg.indexOf(' ') >= 0) {
                        sb.append('"').append(arg).append("\" ");
                    } else {
                        sb.append(arg).append(' ');
                    }
                }
            }
            try {
                runtime.executeCommand(sb.toString());
            } catch (CommandNotFoundException e) {
                System.out.println("Command not found: " + sb.toString());

            } catch (OptionValidatorException | CommandException | CommandValidatorException | IOException | InterruptedException e) {
                System.out.println(e.getMessage());
            }
        }
        System.out.println(runtime.commandInfo(ProteanCommand.COMMAND_NAME));
    }

Line commented on: System.out.println(runtime.commandInfo(ProteanCommand.COMMAND_NAME));

Revised code:
public static void main(String[] args) throws CommandLineParserException {
        CommandRuntime runtime = AeshCommandRuntimeBuilder
                                         .builder()
                                         .commandRegistry(AeshCommandRegistryBuilder.builder().command(ProteanCommand.class).create())
                                         .build();

        if (args.length > 0) {
            StringBuilder sb = new StringBuilder(ProteanCommand.COMMAND_NAME).append(" ");
            if (args.length == 1) {
                sb.append(args[0]);
            } else {
                for (String arg : args) {
                    if (arg.indexOf(' ') >= 0) {
                        sb.append('"').append(arg).append("\" ");
                    } else {
                        sb.append(arg).append(' ');
                    }
                }
            }
            try {
                runtime.executeCommand(sb.toString());
            } catch (CommandNotFoundException e) {
                System.out.println("Command not found: " + sb.toString());

            } catch (OptionValidatorException | CommandException | CommandValidatorException | IOException | InterruptedException e) {
                System.out.println(e.getMessage());
            }
        }
        System.out.println(runtime.commandInfo(ProteanCommand.COMMAND_NAME));
    }
Code review comment: I don't think we support people arbitrarily changing the version of the JDBC driver. We expect them to use the version that comes in the Quarkus BOM.  I just checked and we were also using Oracle-JDBC 23.2.0.0 in Quarkus 3.2/3.3, so this is safe to backport (if we need/want to backport).

Code under review:
RemovedResourceBuildItem enhancedCharsetSubstitutions() {
        return new RemovedResourceBuildItem(ArtifactKey.fromString("com.oracle.database.jdbc:ojdbc11"),
                Collections.singleton("oracle/nativeimage/CharacterSetFeature.class"));
    }

Line commented on: Collections.singleton("oracle/nativeimage/CharacterSetFeature.class"));

Revised code:
RemovedResourceBuildItem enhancedCharsetSubstitutions() {
        return new RemovedResourceBuildItem(ArtifactKey.fromString("com.oracle.database.jdbc:ojdbc11"),
                Collections.singleton("oracle/nativeimage/CharacterSetFeature.class"));
    }
Code review comment: OK, need to look into that, then

Code under review:
private long getThinPoolSize(NodeResources.StorageType storageType) {
        if (storageType == NodeResources.StorageType.local && zone().getCloud().dynamicProvisioning())
            return nodeRepository.resourcesCalculator().thinPoolSizeInBase2Gb(zone(), NodeType.host);
        else
            return 4;
    }

Line commented on: return 4;

Revised code:
private long getThinPoolSize(NodeResources.StorageType storageType) {
        if (storageType == NodeResources.StorageType.local && zone().getCloud().dynamicProvisioning())
            return nodeRepository.resourcesCalculator().thinPoolSizeInBase2Gb(NodeType.host);
        else
            return 4;
    }
Code review comment: I think we should be able to merge this line with the line above as well.

Code under review:
public void visit(BLangRecordLiteral recordLiteral) {
        List<BLangRecordLiteral.BLangRecordKeyValue> keyValuePairs = recordLiteral.keyValuePairs;
        keyValuePairs.forEach(kv -> {
            analyzeExpr(kv.valueExpr);
        });

        Set<Object> names = new TreeSet<>((l, r) -> l.equals(r) ? 0 : 1);
        for (BLangRecordLiteral.BLangRecordKeyValue recFieldDecl : keyValuePairs) {
            BLangExpression key = recFieldDecl.getKey();
            if (key.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
                BLangSimpleVarRef keyRef = (BLangSimpleVarRef) key;
                if (names.contains(keyRef.variableName.value)) {
                    String assigneeType = recordLiteral.parent.type.getKind().typeName();
                    this.dlog.error(key.pos, DiagnosticCode.DUPLICATE_KEY_IN_RECORD_LITERAL,
                            assigneeType, keyRef);
                }
                names.add(keyRef.variableName.value);
            } else if (key.getKind() == NodeKind.LITERAL) {
                BLangLiteral keyLiteral = (BLangLiteral) key;
                if (names.contains(keyLiteral.value)) {
                    String assigneeType = recordLiteral.parent.type.getKind().typeName();
                    this.dlog.error(key.pos, DiagnosticCode.DUPLICATE_KEY_IN_RECORD_LITERAL,
                            assigneeType, keyLiteral);
                }
            }
        }
    }

Line commented on: assigneeType, keyLiteral);

Revised code:
public void visit(BLangRecordLiteral recordLiteral) {
        List<BLangRecordLiteral.BLangRecordKeyValue> keyValuePairs = recordLiteral.keyValuePairs;
        keyValuePairs.forEach(kv -> {
            analyzeExpr(kv.valueExpr);
        });

        Set<Object> names = new TreeSet<>((l, r) -> l.equals(r) ? 0 : 1);
        for (BLangRecordLiteral.BLangRecordKeyValue recFieldDecl : keyValuePairs) {
            BLangExpression key = recFieldDecl.getKey();
            if (key.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
                BLangSimpleVarRef keyRef = (BLangSimpleVarRef) key;
                if (names.contains(keyRef.variableName.value)) {
                    String assigneeType = recordLiteral.parent.type.getKind().typeName();
                    this.dlog.error(key.pos, DiagnosticCode.DUPLICATE_KEY_IN_RECORD_LITERAL, assigneeType, keyRef);
                }
                names.add(keyRef.variableName.value);
            } else if (key.getKind() == NodeKind.LITERAL) {
                BLangLiteral keyLiteral = (BLangLiteral) key;
                if (names.contains(keyLiteral.value)) {
                    String assigneeType = recordLiteral.parent.type.getKind().typeName();
                    this.dlog.error(key.pos, DiagnosticCode.DUPLICATE_KEY_IN_RECORD_LITERAL, assigneeType, keyLiteral);
                }
                names.add(keyLiteral.value);
            }
        }
    }
Code review comment: Are we changing the logger level to `debug` because we expect this race condition to be hit more often?

Code under review:
public static PartitionKeyAccessor getPartitionKeyAccessor() {
            if (!partitionKeyClassLoaded.get()) {
                logger.debug("Initializing PartitionKeyAccessor...");
                PartitionKey.doNothingButEnsureLoadingClass();
            }

            PartitionKeyAccessor snapshot = accessor.get();
            if (snapshot == null) {
                logger.error("PartitionKeyAccessor is not initialized yet!");
                System.exit(9701); 
            }

            return snapshot;
        }

Line commented on: logger.debug("Initializing PartitionKeyAccessor...");

Revised code:
public static PartitionKeyAccessor getPartitionKeyAccessor() {
            if (!partitionKeyClassLoaded.get()) {
                logger.debug("Initializing PartitionKeyAccessor...");
                PartitionKey.doNothingButEnsureLoadingClass();
            }

            PartitionKeyAccessor snapshot = accessor.get();
            if (snapshot == null) {
                logger.error("PartitionKeyAccessor is not initialized yet!");
                System.exit(9701); 
            }

            return snapshot;
        }
Code review comment: Verified locally. It seems it does the job. Please add a test case for this.

Code under review:
private IdentifierNode createIdentifier(String value) {
        IdentifierNode node = TreeBuilder.createIdentifierNode();
        if (value == null) {
            return node;
        }

        if (value.startsWith(IDENTIFIER_LITERAL_PREFIX)) {
            value = StringEscapeUtils.unescapeJava(value);
            node.setValue(value.substring(1));
            node.setLiteral(true);
        } else {
            node.setValue(value);
            node.setLiteral(false);
        }
        return node;
    }

Line commented on: value = StringEscapeUtils.unescapeJava(value);

Revised code:
private IdentifierNode createIdentifier(String value) {
        IdentifierNode node = TreeBuilder.createIdentifierNode();
        if (value == null) {
            return node;
        }

        if (value.startsWith(IDENTIFIER_LITERAL_PREFIX)) {
            value = StringEscapeUtils.unescapeJava(value);
            node.setValue(value.substring(1));
            node.setLiteral(true);
        } else {
            node.setValue(value);
            node.setLiteral(false);
        }
        return node;
    }
Code review comment: ```ballerina function fun() returns int {     return 0; }  public function main() {     worker w returns int {         return 0;     }      future<int> f = start fun();      int res = wait w; // `res` can't be error as multiple reference to same worker is not allowed now,     //  hence we don't need the error component (unless it's coming from return type of w)       int|error intResult = wait f; // this might evaluate to error if we already have waited on `f`      // hence we need the error component here } ```

Code under review:
public void visit(BLangWaitExpr waitExpr) {
        expType = new BFutureType(TypeTags.FUTURE, expType, null);
        checkExpr(waitExpr.getExpression(), env, expType);
        
        if (resultType.tag == TypeTags.UNION) {
            LinkedHashSet<BType> memberTypes = collectMemberTypes((BUnionType) resultType, new LinkedHashSet<>());
            if (memberTypes.size() == 1) {
                resultType = memberTypes.toArray(new BType[0])[0];
            } else {
                resultType = BUnionType.create(null, memberTypes);
            }
        } else if (resultType != symTable.semanticError) {
            
            resultType = ((BFutureType) resultType).constraint;
        }

        if (resultType != symTable.semanticError) {
            resultType = BUnionType.create(null, resultType, symTable.errorType);
        }

        waitExpr.type = resultType;

        if (resultType != null && resultType != symTable.semanticError) {
            types.setImplicitCastExpr(waitExpr, waitExpr.type, ((BFutureType) expType).constraint);
        }
    }

Line commented on: resultType = BUnionType.create(null, resultType, symTable.errorType);

Revised code:
public void visit(BLangWaitExpr waitExpr) {
        expType = new BFutureType(TypeTags.FUTURE, expType, null);
        checkExpr(waitExpr.getExpression(), env, expType);
        
        if (resultType.tag == TypeTags.UNION) {
            LinkedHashSet<BType> memberTypes = collectMemberTypes((BUnionType) resultType, new LinkedHashSet<>());
            if (memberTypes.size() == 1) {
                resultType = memberTypes.toArray(new BType[0])[0];
            } else {
                resultType = BUnionType.create(null, memberTypes);
            }
        } else if (resultType != symTable.semanticError) {
            
            resultType = ((BFutureType) resultType).constraint;
        }

        if (waitExpr.getExpression().getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
            setEventualTypeForWaitExpression((BLangSimpleVarRef) waitExpr.getExpression(), waitExpr.pos);
        } else {
            setEventualTypeForAlternateWaitExpression(waitExpr.getExpression(), waitExpr.pos);
        }
        waitExpr.type = resultType;

        if (resultType != null && resultType != symTable.semanticError) {
            types.setImplicitCastExpr(waitExpr, waitExpr.type, ((BFutureType) expType).constraint);
        }
    }