From 687f92ef4f9e0af7e41f0f1d2e4e6c6267145dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 20 May 2024 19:23:51 +0200 Subject: [PATCH 1/2] Extract `join_ptype_common()` --- R/join-cols.R | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/R/join-cols.R b/R/join-cols.R index 8f7015dd63..873b466ce6 100644 --- a/R/join-cols.R +++ b/R/join-cols.R @@ -181,18 +181,22 @@ add_suffixes <- function(x, y, suffix) { } join_cast_common <- function(x, y, vars, error_call = caller_env()) { + ptype <- join_ptype_common(x, y, vars, error_call) + + # Finalize unspecified columns (#6804) + ptype <- vec_ptype_finalise(ptype) + + vec_cast_common(x = x, y = y, .to = ptype, .call = error_call) +} + +join_ptype_common <- function(x, y, vars, error_call = caller_env()) { # Explicit `x/y_arg = ""` to avoid auto naming in `cnd$x_arg` - ptype <- try_fetch( + try_fetch( vec_ptype2(x, y, x_arg = "", y_arg = "", call = error_call), vctrs_error_incompatible_type = function(cnd) { rethrow_error_join_incompatible_type(cnd, vars, error_call) } ) - - # Finalize unspecified columns (#6804) - ptype <- vec_ptype_finalise(ptype) - - vec_cast_common(x = x, y = y, .to = ptype, .call = error_call) } rethrow_error_join_incompatible_type <- function(cnd, vars, call) { From aa6dc7288eaa13606c905d0e7c38be9266ccafe9 Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Wed, 26 Jun 2024 09:11:20 -0400 Subject: [PATCH 2/2] Move `vec_ptype_finalise()` into `join_ptype_common()` --- R/join-cols.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/join-cols.R b/R/join-cols.R index 873b466ce6..d7c180918c 100644 --- a/R/join-cols.R +++ b/R/join-cols.R @@ -181,22 +181,23 @@ add_suffixes <- function(x, y, suffix) { } join_cast_common <- function(x, y, vars, error_call = caller_env()) { - ptype <- join_ptype_common(x, y, vars, error_call) - - # Finalize unspecified columns (#6804) - ptype <- vec_ptype_finalise(ptype) - + ptype <- join_ptype_common(x, y, vars, error_call = error_call) vec_cast_common(x = x, y = y, .to = ptype, .call = error_call) } join_ptype_common <- function(x, y, vars, error_call = caller_env()) { # Explicit `x/y_arg = ""` to avoid auto naming in `cnd$x_arg` - try_fetch( + ptype <- try_fetch( vec_ptype2(x, y, x_arg = "", y_arg = "", call = error_call), vctrs_error_incompatible_type = function(cnd) { rethrow_error_join_incompatible_type(cnd, vars, error_call) } ) + + # Finalize unspecified columns (#6804) + ptype <- vec_ptype_finalise(ptype) + + ptype } rethrow_error_join_incompatible_type <- function(cnd, vars, call) {