muttakin2301/ccr2000 huggingface dataset:
Code review comment: Also, instead of this can't our first check be isNullable like for union types before iterating through the value space?

Code under review:
private boolean checkFillerValue(BFiniteType type) {
        
        if (type.valueSpace.size() == 1) {
            return true;
        }

        
        Iterator iterator = type.valueSpace.iterator();
        BLangExpression firstElement = (BLangExpression) iterator.next();
        if ((firstElement == null) || (firstElement.type.getKind() == TypeKind.NIL)) {
            return true;
        }

        boolean allMembersHaveSameType = true;
        boolean defaultFillValuePresent = false;

        
        String defaultFillValue = getDefaultFillValue(firstElement);
        if (firstElement.toString().equals(defaultFillValue)) {
            defaultFillValuePresent = true;
        }

        while (iterator.hasNext()) {
            Object value =  iterator.next();
            if (value == null) {
                return true;
            }

            BType valueType = ((BLangExpression) value).type;
            if (valueType.getKind() == TypeKind.NIL) {
                return true;
            }

            if (allMembersHaveSameType && !isSameType(valueType, firstElement.type)) {
                allMembersHaveSameType = false;
            }

            if (!defaultFillValuePresent && value.toString().equals(defaultFillValue)) {
                defaultFillValuePresent = true;
            }
        }

        if (!allMembersHaveSameType) {
            return false;
        }

        return defaultFillValuePresent;
    }

Line commented on: if ((firstElement == null) || (firstElement.type.getKind() == TypeKind.NIL)) {

Revised code:
private boolean checkFillerValue(BFiniteType type) {
        if (type.isNullable()) {
            return true;
        }
        if (type.getValueSpace().size() == 1) { 
            return true;
        }
        Iterator iterator = type.getValueSpace().iterator();
        BLangExpression firstElement = (BLangExpression) iterator.next();
        boolean defaultFillValuePresent = isImplicitDefaultValue(firstElement);

        while (iterator.hasNext()) {
            BLangExpression value = (BLangExpression) iterator.next();
            if (!isSameType(value.type, firstElement.type)) {
                return false;
            }
            if (!defaultFillValuePresent && isImplicitDefaultValue(value)) {
                defaultFillValuePresent = true;
            }
        }

        return defaultFillValuePresent;
    }
Code review comment: No need to call `.stream()`, `Collection` provides `foreach()`.

Code under review:
private TopologicalDocumentTypeSorter(Collection<NewDocumentType> documentTypes) {
        documentTypes.stream().forEach(docType -> unsortedTypes.put(docType.getName(), docType));
        unsortedTypes.values().stream().forEach(docType -> depthFirstTraverse(docType));
    }

Line commented on: documentTypes.stream().forEach(docType -> unsortedTypes.put(docType.getName(), docType));

Revised code:
private TopologicalDocumentTypeSorter(Collection<NewDocumentType> documentTypes) {
        documentTypes.forEach(docType -> unsortedTypes.put(docType.getName(), docType));
        unsortedTypes.values().forEach(docType -> depthFirstTraverse(docType));
    }
Code review comment: > If `Create view` SQL can work well for `single table` currently, do you think `ShardingUnconfiguredTablesRoutingEngine` will be a better match?  @tristaZero `ShardingUnconfiguredTablesRoutingEngine` can meet the needs of creating views on a single data source. I think it is a better choice. 👍

Code under review:
private static Optional<ShardingStatementValidator> getDDLStatementValidator(final SQLStatement sqlStatement) {
        if (sqlStatement instanceof CreateTableStatement) {
            return Optional.of(new ShardingCreateTableStatementValidator());
        }
        if (sqlStatement instanceof CreateFunctionStatement) {
            return Optional.of(new ShardingCreateFunctionStatementValidator());
        }
        if (sqlStatement instanceof CreateProcedureStatement) {
            return Optional.of(new ShardingCreateProcedureStatementValidator());
        }
        if (sqlStatement instanceof CreateViewStatement) {
            return Optional.of(new ShardingCreateViewStatementValidator());
        }
        if (sqlStatement instanceof AlterViewStatement) {
            return Optional.of(new ShardingAlterViewStatementValidator());
        }
        return Optional.empty();
    }

Line commented on: if (sqlStatement instanceof AlterViewStatement) {

Revised code:
private static Optional<ShardingStatementValidator> getDDLStatementValidator(final SQLStatement sqlStatement) {
        if (sqlStatement instanceof CreateTableStatement) {
            return Optional.of(new ShardingCreateTableStatementValidator());
        }
        if (sqlStatement instanceof CreateFunctionStatement) {
            return Optional.of(new ShardingCreateFunctionStatementValidator());
        }
        if (sqlStatement instanceof CreateProcedureStatement) {
            return Optional.of(new ShardingCreateProcedureStatementValidator());
        }
        if (sqlStatement instanceof CreateViewStatement) {
            return Optional.of(new ShardingCreateViewStatementValidator());
        }
        if (sqlStatement instanceof AlterViewStatement) {
            return Optional.of(new ShardingAlterViewStatementValidator());
        }
        return Optional.empty();
    }
Code review comment: ... well, if the connection had several requests, I guess that could explain the difference.

Code under review:
private static long doomMillis(HttpRequest request) {
        long connectedAtMillis = request.getConnectedAt(MILLISECONDS);
        long requestTimeoutMillis = getProperty(request, TIMEOUT, timeoutMillisParser).orElse(defaultTimeout.toMillis());
        return connectedAtMillis + requestTimeoutMillis;
    }

Line commented on: long connectedAtMillis = request.getConnectedAt(MILLISECONDS);

Revised code:
private static long doomMillis(HttpRequest request) {
        long createdAtMillis = request.creationTime(MILLISECONDS);
        long requestTimeoutMillis = getProperty(request, TIMEOUT, timeoutMillisParser).orElse(defaultTimeout.toMillis());
        return createdAtMillis + requestTimeoutMillis;
    }
Code review comment: Yes this is a good idea, I pushed an update.

Code under review:
void verifyBuildFile() {
        for (String buildFileName : buildTool.getBuildFiles()) {
            File buildFile = projectRoot.resolve(buildFileName).toFile();
            if (buildFile.exists()) {
                return;
            }
        }
        throw new IllegalStateException("Was not able to find a build file in: " + projectRoot);
    }

Line commented on: throw new IllegalStateException("Was not able to find a build file in: " + projectRoot);

Revised code:
void verifyBuildFile() {
        for (String buildFileName : buildTool.getBuildFiles()) {
            File buildFile = projectRoot.resolve(buildFileName).toFile();
            if (buildFile.exists()) {
                return;
            }
        }
        throw new IllegalStateException("Was not able to find a build file in: " + projectRoot
                + " based on the following list: " + String.join(",", buildTool.getBuildFiles()));
    }
Code review comment: looks like can build this once before injection above

Code under review:
private Context startSpan(HttpPipelineCallContext azContext) {
        Context parentContext = getTraceContextOrCurrent(azContext);

        HttpRequest request = azContext.getHttpRequest();

        
        String methodName = request.getHttpMethod().toString();
        Span span = tracer.spanBuilder("HTTP " + methodName)
            .setAttribute(HTTP_METHOD, methodName)
            .setAttribute(HTTP_URL, request.getUrl().toString())
            .setParent(parentContext)
            .setSpanKind(SpanKind.CLIENT)
            .startSpan();

        
        if (span.isRecording()) {
            addPostSamplingAttributes(span, request, azContext);
        }

        
        SpanContext spanContext = span.getSpanContext();
        if (spanContext.isValid()) {
            traceContextFormat.inject(parentContext.with(span), request, contextSetter);
        }

        return parentContext.with(span);
    }

Line commented on: return parentContext.with(span);

Revised code:
private Context startSpan(HttpPipelineCallContext azContext) {
        Context parentContext = getTraceContextOrCurrent(azContext);

        HttpRequest request = azContext.getHttpRequest();

        
        String methodName = request.getHttpMethod().toString();
        Span span = tracer.spanBuilder("HTTP " + methodName)
            .setAttribute(HTTP_METHOD, methodName)
            .setAttribute(HTTP_URL, request.getUrl().toString())
            .setParent(parentContext)
            .setSpanKind(SpanKind.CLIENT)
            .startSpan();

        if (span.isRecording()) {
            addPostSamplingAttributes(span, request, azContext);
        }

        Context traceContext = parentContext.with(span);
        traceContextFormat.inject(traceContext, request, contextSetter);
        return traceContext;
    }
Code review comment: ```suggestion                     + " Quarkus currently supports GraalVM 19.3.1 and 20.0.0." ```

Code under review:
private void checkGraalVMVersion(String version) {
        log.info("Running Quarkus native-image plugin on " + version);
        final List<String> obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.", "19.3.0");
        final boolean vmVersionIsObsolete = obsoleteGraalVmVersions.stream().anyMatch(v -> version.contains(" " + v));
        if (vmVersionIsObsolete) {
            throw new IllegalStateException("Unsupported version of GraalVM detected: " + version + "."
                    + " Quarkus currently offers a stable support of GraalVM 19.3.1 and 20.0.0."
                    + " Please upgrade GraalVM to one of these versions.");
        }
    }

Line commented on: + " Quarkus currently offers a stable support of GraalVM 19.3.1 and 20.0.0."

Revised code:
private void checkGraalVMVersion(String version) {
        log.info("Running Quarkus native-image plugin on " + version);
        final List<String> obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.", "19.3.0");
        final boolean vmVersionIsObsolete = obsoleteGraalVmVersions.stream().anyMatch(v -> version.contains(" " + v));
        if (vmVersionIsObsolete) {
            throw new IllegalStateException("Out of date version of GraalVM detected: " + version + "."
                    + " Quarkus currently supports GraalVM 19.3.1 and 20.0.0. Please upgrade GraalVM to one of these versions.");
        }
    }
Code review comment: yes, but range can be use in first column

Code under review:
private int calcSortScore(MaterializedView mv, Set<String> equivalenceColumns, Set<String> nonEquivalenceColumns) {
        List<Column> schema = mv.getBaseSchema();
        int score = 0;
        for (Column col : schema) {
            String columName = col.getName().toLowerCase();
            if (equivalenceColumns.contains(columName)) {
                score++;
            } else if (nonEquivalenceColumns.contains(columName)) {
                
                score++;
                break;
            } else {
                break;
            }
        }
        return score;
    }


Revised code:
private int calcSortScore(MaterializedView mv, Set<String> equivalenceColumns, Set<String> nonEquivalenceColumns) {
        List<Column> keyColumns = mv.getKeyColumnsByIndexId(mv.getBaseIndexId());
        int score = 0;
        for (Column col : keyColumns) {
            String columName = col.getName().toLowerCase();
            if (equivalenceColumns.contains(columName)) {
                score++;
            } else if (nonEquivalenceColumns.contains(columName)) {
                
                score++;
                break;
            } else {
                break;
            }
        }
        return score;
    }
Code review comment: Just a questions: why do we need to create a new symbol environment here?

Code under review:
public void visit(BLangTransaction transactionNode) {
        SymbolEnv transactionEnv = SymbolEnv.createTransactionEnv(transactionNode, env);
        analyzeStmt(transactionNode.transactionBody, transactionEnv);
        if (transactionNode.onRetryBody != null) {
            analyzeStmt(transactionNode.onRetryBody, transactionEnv);
        }

        if (transactionNode.committedBody != null) {
            analyzeStmt(transactionNode.committedBody, transactionEnv);
        }

        if (transactionNode.abortedBody != null) {
            analyzeStmt(transactionNode.abortedBody, transactionEnv);
        }

        if (transactionNode.retryCount != null) {
            typeChecker.checkExpr(transactionNode.retryCount, transactionEnv, symTable.intType);
            checkRetryStmtValidity(transactionNode.retryCount);
        }
    }

Line commented on: SymbolEnv transactionEnv = SymbolEnv.createTransactionEnv(transactionNode, env);

Revised code:
public void visit(BLangTransaction transactionNode) {
        SymbolEnv transactionEnv = SymbolEnv.createTransactionEnv(transactionNode, env);
        analyzeStmt(transactionNode.transactionBody, transactionEnv);
        if (transactionNode.onRetryBody != null) {
            analyzeStmt(transactionNode.onRetryBody, transactionEnv);
        }

        if (transactionNode.committedBody != null) {
            analyzeStmt(transactionNode.committedBody, transactionEnv);
        }

        if (transactionNode.abortedBody != null) {
            analyzeStmt(transactionNode.abortedBody, transactionEnv);
        }

        if (transactionNode.retryCount != null) {
            typeChecker.checkExpr(transactionNode.retryCount, transactionEnv, symTable.intType);
            checkRetryStmtValidity(transactionNode.retryCount);
        }
    }
Code review comment: `StreamElementQueueEntry<OUT> queueEntry` to avoid unchecked.

Code under review:
public Optional<ResultFuture<OUT>> tryPut(StreamElement streamElement) {
		if (queue.size() < capacity) {
			StreamElementQueueEntry queueEntry = createEntry(streamElement);

			queue.add(queueEntry);

			LOG.debug("Put element into ordered stream element queue. New filling degree " +
				"({}/{}).", queue.size(), capacity);

			return Optional.of(queueEntry);
		} else {
			LOG.debug("Failed to put element into ordered stream element queue because it " +
				"was full ({}/{}).", queue.size(), capacity);

			return Optional.empty();
		}
	}

Line commented on: StreamElementQueueEntry queueEntry = createEntry(streamElement);

Revised code:
was full ({}
Code review comment: nit: These tests have not been migrated to AssertJ. We will do this later.

Code under review:
public void testMissingWebIdentityTokenFileInCredentials() {
        exception.expect(IllegalStateException.class);
        exception.expectMessage(
                "Either the environment variable AWS_WEB_IDENTITY_TOKEN_FILE or the javaproperty aws.webIdentityTokenFile must be set");
        Properties properties = TestUtil.getStandardProperties();
        properties.setProperty(AWS_CREDENTIALS_PROVIDER, "WEB_IDENTITY_TOKEN");

        AWSGeneralUtil.validateAwsCredentials(properties);
    }

Line commented on: exception.expectMessage(

Revised code:
public void testMissingWebIdentityTokenFileInCredentials() {
        exception.expect(IllegalStateException.class);
        exception.expectMessage(
                "Either the environment variable AWS_WEB_IDENTITY_TOKEN_FILE or the javaproperty aws.webIdentityTokenFile must be set");
        Properties properties = TestUtil.getStandardProperties();
        properties.setProperty(AWS_CREDENTIALS_PROVIDER, "WEB_IDENTITY_TOKEN");

        AWSGeneralUtil.validateAwsCredentials(properties);
    }