Github user windpiger commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17149#discussion_r104358279
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalogSuite.scala
 ---
    @@ -883,7 +885,7 @@ abstract class CatalogTestUtils {
     
       def newFunc(): CatalogFunction = newFunc("funcName")
     
    -  def newUriForDatabase(): String = 
Utils.createTempDir().toURI.toString.stripSuffix("/")
    +  def newUriForDatabase(): URI = new 
URI(Utils.createTempDir().toURI.toString.stripSuffix("/"))
    --- End diff --
    
    @cloud-fan  after I try to use Path to Compare , I think stripSuffix here 
is the simple way.
    
    Path with a `String` type constructor will be equal when one has a `/`, and 
another does not.
    ```
    scala> val x = new Path("/ab/c/")
    x: org.apache.hadoop.fs.Path = /ab/c
    
    scala> val y = new Path("/ab/c")
    y: org.apache.hadoop.fs.Path = /ab/c
    
    scala> x == y
    res0: Boolean = true
    ```
    
    Path with a `URI` type constructor will be not equal when one has a `/`, 
and another does not.
    ```
    scala> val x =new URI("/a/b/c/")
    x: java.net.URI = /a/b/c/
    
    scala> val y =new URI("/a/b/c")
    y: java.net.URI = /a/b/c
    
    scala> x == y
    res1: Boolean = false
    
    scala> val x1 =new Path(x)
    x1: org.apache.hadoop.fs.Path = /a/b/c/
    
    scala> val y1 =new Path(y)
    y1: org.apache.hadoop.fs.Path = /a/b/c
    
    scala> x1 == y1
    res2: Boolean = false
    ```
    
    So just the Path with `String` type can ignore the suffix `/`, then if we 
have a `URI` in hand, and we want to compare with another `URI`, we should  
first transform them to `String` , and use this String to constructor a Path, 
after this two actions, we can compare them with ignore the suffix `/`.
    
    But I think it is more complicate, here we normalize the URI with 
stripSuffix from the Orignal then compare two URI directly, it is more simple.
    
    should we must to convert it to Path to compare?



---
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