Skip to content

feat: ✨ conversion log schema comparison#301

Open
signekb wants to merge 9 commits into
mainfrom
feat/conversion-log-schema
Open

feat: ✨ conversion log schema comparison#301
signekb wants to merge 9 commits into
mainfrom
feat/conversion-log-schema

Conversation

@signekb
Copy link
Copy Markdown
Contributor

@signekb signekb commented May 28, 2026

Description

This adds an exported log_schema() function with quite a few helpers. I've tried implementing it so it outputs a S3 object with a specified print() method, so it can be called in the conversion-log.qmd in the same way as log_as_table().

Looking forward to feedback 😁

Closes #287

Needs a thorough review.

Checklist

  • Ran just run-all

@signekb signekb moved this from In review to In progress in Platform development May 29, 2026
@signekb signekb moved this from In progress to In review in Platform development May 29, 2026
Copy link
Copy Markdown
Member

@lwjohnst86 lwjohnst86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start! 🎉

Comment thread R/log.R
Comment on lines +6 to +7
#' @param register_log A tibble returned by [convert()], filtered to only
#' contain rows from a single register.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't require only a single register, why the change here?

Comment thread R/log.R
#' sas_file <- fs::path_package("fastreg", "extdata", "test.sas7bdat")
#' conversion_log <- convert(sas_file, output_dir = fs::path_temp("output"))
#' log_schema(conversion_log)
log_schema <- function(register_log) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't doing the action of logging. Could you use another verb here? Based on comment below, this could be print_log() instead.

Comment thread R/log.R
#' sas_file <- fs::path_package("fastreg", "extdata", "test.sas7bdat")
#' conversion_log <- convert(sas_file, output_dir = fs::path_temp("output"))
#' log_schema(conversion_log) |> print()
print.fastreg_schema <- function(x, ...) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of an S3 😁 But, could this not be moved into the function above and then that function could be called print_log()? I'm not sure it is necessary to use S3 here. Would log_schema() be used for anything else other than printing the differences/etc?

Comment thread R/log.R
knitr::kable() |>
print()
if (length(x$diff_tables) > 0) {
cat("### Schema differences\n\n")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cat("### Schema differences\n\n")
cat("\n\n### Schema differences\n\n")

Since the previous table is right above this header, so needs more empty lines above it.

Comment thread R/log.R
#' conversion_log <- convert(sas_file, output_dir = fs::path_temp("output"))
#' log_schema(conversion_log) |> print()
print.fastreg_schema <- function(x, ...) {
cat(x$description, "\n\n")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cat(x$description, "\n\n")
cat(x$description)

It looks like knitr::kable puts new lines above the table by default.

Comment thread R/log.R
#' conversion_log <- convert(sas_file, output_dir = fs::path_temp("output"))
#' log_schema(conversion_log) |> print()
print.fastreg_schema <- function(x, ...) {
cat(x$description, "\n\n")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rather than using cat() everywhere, you create a character vector with all the items in that single variable, than at the end print that.

Comment thread R/log.R
#' the reference schema. If there's many files with schema differences,
#' there will be multiple tables, for printing purposes.
#'
#' @importFrom rlang .data
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be placed in a file called fastreg-package.R made by usethis::use_package_doc(). All imports like that are then put in that file to keep track of them.

@github-project-automation github-project-automation Bot moved this from In review to In progress in Platform development May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[discussion]: Conversion log content/output

2 participants