错误:未找到:值StructType / StructField / StringType

时间:2016-09-07 08:27:06

标签: scala apache-spark

我在本地计算机上运行scala,版本2.0。

Option Explicit
Private Type ArrayBounds
    Lower As Long
    Upper As Long
    Index As Long
    WantedDimension As Boolean
    DiscardIndex As Long
End Type
Public Sub RunMe()
    Dim arr As Variant
    Dim result As Variant

    arr = CreateDummyArray
    result = Extract(arr, 1, 3, 11)

End Sub
Private Function Extract(arr As Variant, i1 As Integer, i2 As Integer, ParamArray ov() As Variant) As Variant
    Dim d As Long
    Dim bounds() As ArrayBounds
    Dim i As Long
    Dim v As Variant
    Dim ovIndex As Long
    Dim doExtract As Boolean
    Dim result() As Variant

    'Dimension the output array
    ReDim result(LBound(arr, i1) To UBound(arr, i1), LBound(arr, i2) To UBound(arr, i2))

    'Get no. of dimensions in array
    d = GetDimension(arr)

    'Now we know the number of dimensions,
    'we can check that the passed parameters are correct
    If (i1 < 1 Or i1 > d) Or (i2 < 1 Or i2 > d) Then
        MsgBox "i1/i2 - out of range"
        Exit Function
    End If

    If UBound(ov) - LBound(ov) + 1 <> d - 2 Then
        MsgBox "ov - wrong number of args"
        Exit Function
    End If

    'Resise and populate the bounds type array
    ReDim bounds(1 To d)
    ovIndex = LBound(ov)
    For i = 1 To d
        With bounds(i)
            .Lower = LBound(arr, i)
            .Upper = UBound(arr, i)
            .Index = .Lower
            .WantedDimension = (i = i1) Or (i = i2)
            If Not .WantedDimension Then
                .DiscardIndex = ov(ovIndex)
                ovIndex = ovIndex + 1
                'Check index is in range
                If .DiscardIndex < .Lower Or .DiscardIndex > .Upper Then
                    MsgBox "ov - out of range"
                    Exit Function
                End If
            End If
        End With
    Next

    'Iterate each member of the multi-dimensional array with a For Each
    For Each v In arr
        'Check if this combination of indexes is wanted for extract
        doExtract = True
        For i = 1 To d
            With bounds(i)
                If Not .WantedDimension And .Index <> .DiscardIndex Then
                    doExtract = False
                    Exit For
                End If
            End With
        Next

        'Write value into output array
        If doExtract Then
            result(bounds(i1).Index, bounds(i2).Index) = v
        End If

        'Increment the dimension index
        For i = 1 To d
            With bounds(i)
                .Index = .Index + 1
                If .Index > .Upper Then .Index = .Lower Else Exit For
            End With
        Next

    Next

    Extract = result
End Function
Private Function GetDimension(arr As Variant) As Long
    'Helper function to obtain number of dimensions
    Dim i As Long
    Dim test As Long

    On Error GoTo GotIt
    For i = 1 To 60000
        test = LBound(arr, i)
    Next
    Exit Function
GotIt:
    GetDimension = i - 1
End Function

我加载了导入org.apache.spark.sql._但仍然收到此错误。我错过了任何套餐吗?

1 个答案:

答案 0 :(得分:21)

import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType};

尝试导入