-
Notifications
You must be signed in to change notification settings - Fork 274
feat(amazonq): support SQL conversions #4995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QDJVMC found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
...oftware/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt
Fixed
Show fixed
Hide fixed
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Fixed
Show fixed
Hide fixed
.../src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformFileUtils.kt
Fixed
Show fixed
Hide fixed
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Fixed
Show fixed
Hide fixed
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Fixed
Show fixed
Hide fixed
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Fixed
Show fixed
Hide fixed
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Fixed
Show fixed
Hide fixed
deb935c to
d464830
Compare
...are/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt
Outdated
Show resolved
Hide resolved
...mmunity/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerManager.kt
Show resolved
Hide resolved
...mmunity/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerManager.kt
Show resolved
Hide resolved
...oftware/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt
Outdated
Show resolved
Hide resolved
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Show resolved
Hide resolved
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Outdated
Show resolved
Hide resolved
...lkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt
Show resolved
Hide resolved
.../jetbrains/services/codemodernizer/panels/managers/CodeModernizerBottomWindowPanelManager.kt
Show resolved
Hide resolved
| ) { | ||
| maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading")) | ||
| maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building")) | ||
| maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building")) | ||
| maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning")) | ||
| maybeAdd(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming")) | ||
| maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading")) | ||
| maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building")) | ||
| maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning")) | ||
| maybeAddTransformationStep(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| loadingPanelText = if (transformType == CodeTransformType.SQL_CONVERSION) { | ||
| message("codemodernizer.toolwindow.scan_in_progress.transforming") | ||
| } else { | ||
| message("codemodernizer.toolwindow.scan_in_progress.planning") |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| TransformationStatus.PLANNED -> { | ||
| loadingPanelText = message("codemodernizer.toolwindow.scan_in_progress.planning") | ||
| loadingPanelText = if (transformType == CodeTransformType.SQL_CONVERSION) { | ||
| message("codemodernizer.toolwindow.scan_in_progress.transforming") |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
|
|
||
| fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult { | ||
| if (sctFile == null) { | ||
| return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.missing_sct_file")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| val targetDbServer = targets["DbServer"] as Map<*, *> | ||
| val targetVendor = (targetDbServer["vendor"] as String).trim().uppercase() | ||
| if (targetVendor != "AURORA_POSTGRESQL" && targetVendor != "RDS_POSTGRESQL") { | ||
| return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_target_db")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| return SqlMetadataValidationResult(true, "", sourceVendor, targetVendor, sourceServerName, schemaNames) | ||
| } catch (e: Exception) { | ||
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file: $e" } | ||
| return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
ad1db16 to
1e9ddf8
Compare
.../src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformFileUtils.kt
Outdated
Show resolved
Hide resolved
.../software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt
Show resolved
Hide resolved
.../software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt
Outdated
Show resolved
Hide resolved
|
TODO: add changelog entry |
| private val confirmUserSelectionSQLConversionMetadataButton = Button( | ||
| keepCardAfterClick = true, | ||
| waitMandatoryFormItems = true, | ||
| text = message("codemodernizer.chat.message.button.select_sql_metadata"), |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| """.trimIndent() | ||
|
|
||
| private fun getUserSQLConversionSelectionFormattedMarkdown(moduleName: String, schema: String) = """ | ||
| ### ${message("codemodernizer.chat.prompt.title.details")} |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
.../software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt
Fixed
Show fixed
Hide fixed
| sctMetadata = xmlMapper.readValue<SctMetadata>(sctFile) | ||
| } catch (e: Exception) { | ||
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered. $e" } | ||
| return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct")) |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
...rc/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt
Fixed
Show fixed
Hide fixed
...rc/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt
Fixed
Show fixed
Hide fixed
...rc/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt
Fixed
Show fixed
Hide fixed
...rc/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt
Fixed
Show fixed
Hide fixed
| private const val METRICS_FILE_NAME = "metrics.json" | ||
| val LOG = getLogger<CodeModernizerArtifact>() | ||
| val MAPPER = jacksonObjectMapper() | ||
| val XML_MAPPER = XmlMapper().registerKotlinModule().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
Check notice
Code scanning / QDJVMC
Function or property has platform type Note
| fun buildSQLMetadataValidationSuccessDetailsChatContent(validationResult: SqlMetadataValidationResult) = CodeTransformChatMessageContent( | ||
| type = CodeTransformChatMessageType.FinalizedAnswer, | ||
| message = """ | ||
| ### ${message("codemodernizer.chat.prompt.title.details")} |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| } | ||
|
|
||
| override suspend fun processCodeTransformSelectSQLMetadataAction(message: IncomingCodeTransformMessage.CodeTransformSelectSQLMetadata) { | ||
| runInEdt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is suspend, so you can just do withContext(EDT) {
| val metadataValidationResult = validateSctMetadata(sctFile) | ||
|
|
||
| if (!metadataValidationResult.valid) { | ||
| CoroutineScope(EDT).launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are already on EDT, so what is this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using withContext(EDT) means that I no longer need to do this, previously was getting an error, fixed
| val metadataValidationResult = validateSctMetadata(sctFile) | ||
|
|
||
| if (!metadataValidationResult.valid) { | ||
| CoroutineScope(EDT).launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this breaks structured concurrency, should be withContext(...)/launch(...) depending on desired behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed entirely in favor of withContext
| try { | ||
| sctMetadata = XML_MAPPER.readValue<SctMetadata>(sctFile) | ||
| } catch (e: Exception) { | ||
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered. $e" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our linter is broken and not catching this for some reason
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered. $e" } | |
| getLogger<CodeTransformChatController>(e).error { "Error parsing .sct metadata file; invalid XML encountered." } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried this, got errors prompting me to make changes in LogUtils.kt and some other shared/common files, wasn't sure if I should do that, ideally that can be a follow up, for now I changed it to just log the localizedMessage rather than dumping the entire Error object
| } | ||
| return SqlMetadataValidationResult(true, "", sourceVendor, targetVendor, sourceServerName, schemaNames) | ||
| } catch (e: Exception) { | ||
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file: $e" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file: $e" } | |
| getLogger<CodeTransformChatController>(e).error { "Error parsing .sct metadata file" } |
Types of changes
Description
QCT wants to support converting embedded SQL in Java apps.
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.