Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8711#discussion_r39367671
  
    --- Diff: R/pkg/R/schema.R ---
    @@ -131,13 +131,31 @@ checkType <- function(type) {
       if (type %in% primtiveTypes) {
         return()
       } else {
    -    m <- regexec("^array<(.*)>$", type)
    -    matchedStrings <- regmatches(type, m)
    -    if (length(matchedStrings[[1]]) >= 2) {
    -      elemType <- matchedStrings[[1]][2]
    -      checkType(elemType)
    -      return()
    -    }
    +    # Array type
    +    firstChar <- substr(type, 1, 1)
    +    switch (firstChar,
    +            a = {
    +              # Array type
    +              m <- regexec("^array<(.*)>$", type)
    +              matchedStrings <- regmatches(type, m)
    +              if (length(matchedStrings[[1]]) >= 2) {
    +                elemType <- matchedStrings[[1]][2]
    +                checkType(elemType)
    +                return()
    +              }
    +            },
    +            m = {
    +              # Map type
    +              m <- regexec("^map<(.*),(.*)>$", type)
    +              matchedStrings <- regmatches(type, m)
    +              if (length(matchedStrings[[1]]) >= 3) {
    +                keyType <- matchedStrings[[1]][2]
    +                valueType <- matchedStrings[[1]][3]
    +                checkType(keyType)
    --- End diff --
    
    yeah, good catch. Should check if the key type is String. Also need to add 
check on Scala side.
    
    It seems a little boring that doing type check on both R and Scala side. 
Maybe we can remove the type check on R side. Not sure for now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to