我正在尝试使用与此类似的方法从数据块笔记本中批量插入 SQL Server 表:
批量复制到 Azure SQL 数据库或 SQL Server
这工作正常,直到我尝试写入数据类型为日期时间的列。我试图写入的表具有以下架构:
create table raw.HubDrg_TEST
(
  DrgKey varchar(64) not null,
  LoadDate datetime,
  LoadProcess varchar(255),
  RecordSource varchar(255),
  DrgCode varchar(255)
 )
我的Scala代码如下:
//Get dataset for data in staging table
var stagedData: DataFrame = spark.read
  .format("com.databricks.spark.sqldw")
  .option("url", sqlDwUrlSmall)
  .option("tempDir", tempDir)
  .option("forwardSparkAzureStorageCredentials", "true")
  .option("query", "select distinct CodeID as DrgCode, getdate() as LoadDate from StageMeditech.livendb_dbo_DAbsDrgs").load() 
//Get dataset for data in existing Hub
val existingHub: DataFrame = spark.read
  .format("com.databricks.spark.sqldw")
  .option("url", sqlDwUrlSmall)
  .option("tempDir", tempDir)
  .option("forwardSparkAzureStorageCredentials", "true")
  .option("query", "Select …我在这里尝试反序列化这个JSON时遇到了麻烦:
{
    "response": {
        "numfound": 1,
        "start": 0,
        "docs": [
            {
                "enID": "9999",
                "startDate": "2013-09-25",
                "bName": "XXX",
                "pName": "YYY",
                "UName": [
                    "ZZZ"
                ],
                "agent": [
                    "BobVilla"
                ]
            }
        ]
    }
}
我为此创建的类是:
public class ResponseRoot {
    public Response response;
}
public class Response {
    public int numfound { get; set; }
    public int start { get; set; }
    public Docs[] docs;
}
public class Docs {
    public string enID { get; set; }
    public string startDate { get; set; } …我使用的例子在这个环节在这里从一个目录复制HDFS内容在HDFS另一个目录。复制文件是可行的,但是与仅将文件复制到目标目录相比,它在目标中创建了一个新的子目录。例:
  Path source=new Path("hdfs://HANameService/sources/hpm_support/apc_code/");
  Path target=new Path("hdfs://HANameService/staging/hpm_support/apc_code/");
  FileSystem fs = source.getFileSystem(conf); 
  FileUtil.copy(fs, source, fs, target, true, conf);`
因此,hdfs://HANameService/staging/hpm_support/apc_code与其将文件复制到该文件,而是在apc_code下创建一个新目录,该文件最终显示在hdfs://HANameService/staging/hpm_support/apc_code/apc_code如何获取而不创建该子目录的位置?
我试图在我的脚本组件转换中从PipelineBuffer获取列名和索引是SSIS并将它们添加到Hashtable.我知道如果我将我的类public class ScriptMain : UserComponent改为:ScriptMain : PipelineComponent并使用此代码,这是可能的:
public override void ProcessInput(int InputID, Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer Buffer)
{
    inputBuffer = Buffer;
    hash = new Hashtable();
    IDTSInput100 i = ComponentMetaData.InputCollection.GetObjectByID(InputID);
    foreach (IDTSInputColumn100 col in i.InputColumnCollection)
    {
        int colIndex = BufferManager.FindColumnByLineageID(i.Buffer, col.LineageID);
        hash.Add(col.Name, colIndex);
    }
}
然而; 当我这样做时,我不能再覆盖:public override void Input0_ProcessInputRow(Input0Buffer Row)因为这在PipelineComponent类中不可用,并且我不能再通过调用这样的东西来访问我的连接管理器:IDTSConnectionManager100 connMgr = this.Connections.DbConnection;从我所看到的,UserComponent类中没有BufferManager.有没有办法使用UserComponent完成此任务?
c# ×2
apache-spark ×1
databricks ×1
hadoop ×1
hdfs ×1
java ×1
json ×1
scala ×1
sql-server ×1
ssis ×1