aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/R/schema.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/pkg/R/schema.R')
-rw-r--r--R/pkg/R/schema.R28
1 files changed, 26 insertions, 2 deletions
diff --git a/R/pkg/R/schema.R b/R/pkg/R/schema.R
index 8df1563f8e..6f0e9a94e9 100644
--- a/R/pkg/R/schema.R
+++ b/R/pkg/R/schema.R
@@ -136,7 +136,7 @@ checkType <- function(type) {
switch (firstChar,
a = {
# Array type
- m <- regexec("^array<(.*)>$", type)
+ m <- regexec("^array<(.+)>$", type)
matchedStrings <- regmatches(type, m)
if (length(matchedStrings[[1]]) >= 2) {
elemType <- matchedStrings[[1]][2]
@@ -146,7 +146,7 @@ checkType <- function(type) {
},
m = {
# Map type
- m <- regexec("^map<(.*),(.*)>$", type)
+ m <- regexec("^map<(.+),(.+)>$", type)
matchedStrings <- regmatches(type, m)
if (length(matchedStrings[[1]]) >= 3) {
keyType <- matchedStrings[[1]][2]
@@ -157,6 +157,30 @@ checkType <- function(type) {
checkType(valueType)
return()
}
+ },
+ s = {
+ # Struct type
+ m <- regexec("^struct<(.+)>$", type)
+ matchedStrings <- regmatches(type, m)
+ if (length(matchedStrings[[1]]) >= 2) {
+ fieldsString <- matchedStrings[[1]][2]
+ # strsplit does not return the final empty string, so check if
+ # the final char is ","
+ if (substr(fieldsString, nchar(fieldsString), nchar(fieldsString)) != ",") {
+ fields <- strsplit(fieldsString, ",")[[1]]
+ for (field in fields) {
+ m <- regexec("^(.+):(.+)$", field)
+ matchedStrings <- regmatches(field, m)
+ if (length(matchedStrings[[1]]) >= 3) {
+ fieldType <- matchedStrings[[1]][3]
+ checkType(fieldType)
+ } else {
+ break
+ }
+ }
+ return()
+ }
+ }
})
}