DATASTAGE——DATASTAGE经验积累 下载本文

内容发布更新时间 : 2024/5/16 23:17:32星期一 下面是文章的全部内容请认真阅读。

.

系统或操作型数据库的数据,转换这些数据或将它们与其他数据源集成在一起,然后将它们写成XML文档.通过XML阅读器可以将XML文档读入或导入DataStage.而且DataStage可以将XML文档中的数据与其他数据源集成在一起,对它们进行转换,然后写成XML文档或任何其他支持的数据目标.

用户可以将XML用作数据的封装格式,也可以用作描述元数据的标准方式.通过为抽取元数据而设立的XML封装文档类型定义方式,DataStage可以支持导出和导入数据集成过程中涉及到的所有元数据.在将元数据导出到XML文档中时,DataStage提供了文档类型定义从而使其他工具软件也可以理解导出文档的结构与内容.此外XML封装还允许用户将XML元数据从任何一种报表中导出并写成XML文档,此类报表包括目录、术语表和衍生报表.之后用户就只需使用支持XML的浏览器或将文档导入任何其他支持XML的应用程序中就可以阅读这些导出的文档了.

trim会drop掉记录 当一条记录过来,某个字段为空,而在transformer中又对该字段trim了,由于该字段为空,不能trim,所以DataStage会认为这是个错误,从而把这个记录drop了,这与实际业务不符合,非主键字段为空并不能就把这条记录drop了。

我们可以通过写一个判断来解决该问题:

if LK_1.EMAIL <> '' then trim(LK_1.EMAIL) else LK_1.EMAIL

DataStage中可以执行routine,命令行以控制的地方

1 before/after job和before/after stage,可以执行shell,命令行以及一些DataStage API,如DSJobReport

2 job sequence中有个stage,可以在里面写控制job调度的地方 3 每个job的properties中有个job control tab

4 命令行可以执行、导入job等,它通过dsjob实现,在DS Manager的文档中还讲了有专门的命令行来导入job

5 可以编写shell来控制job,对dsjob命令做封装,可以传入参数等。 对于上面这些概念还是很模糊,先记录在此。

trim全为null的某个字段之后,输出为0

今天又碰到新问题,在transformer中,进去是有很多record,出来之后为0条record,用peek,看了一下,进去的数据的某个字段数据全为null,而在transformer中对此字段trim了,改为不trim就可以了。

job一直运行,数据不能插入数据库

今天遇到一个问题,job不停的在那里运行,然后link上的数据显示各个环节都是正确的,包括最后插入数据库的link上也显示了数据,但是最后数据库里并没有数据。在Director的log中,日志在从两个源文件把所有数据load出来完之后,日志就死在那里了。

以前这个job是正确的,昨天由于重新load其中一个源文件的元数据,所以出现了上述问题。所以先前以为是由于load的新的源数据有问题,就从此处来找问题的原因,并且认为可能是改了元数据,在其他地方映射的时候有位置不对的地方,所以整了很久。因为以前是好好的,然后又以为是服务器的问题。

这都是定势思维的错误,然后又一急,所以浪费了很多时间,其实很多时候都是这样,出了问题我们不能理性的好好思考。

其实问题很简单:

..

.

如果我们按照正常逻辑来分析的话,既然不能读入数据库,肯定是数据不符合数据库对数据的约束,包括主键啊,非空啊,本问题就是由于在stage的不断流转中产生了很多空格,使得最后待插入的数据长度远远大于数据库中定义的字段长度。由于在那里不断reject,所以影响了速度,job一直在那里运行。最后用APT_STRING_PADDER,将其设为0x0(用null代替空格)搞定。

ps:在插入数据库时使用一个reject文件对查错有好处,这样能看到reject是些什么数据,然后就能知道为什么被reject了。

同时我们可以得出如果最后插入数据库时很多数据被reject,但是你并没有用一个reject文件来接收这些reject掉的数据,将使得job基本处于停滞状态。

ETL时先disable外键约束再load数据

Kimball在他的ETL Toolkit一书中,一直强调:对于有外键约束的表,为了提高load的速度,可以先将外键约束disable,加载完成后再enable(当然另外一个原因是进入数据仓库的数据都是规范的,甚至可以考虑不使用外键约束,即违反约束的数据在Transformation部分就应该解决掉,当然这是设计问题了)。ps:另外两个提高load速度的方法分别为使用sql loader和insert、update分离。当时还不是明白这个过程怎么具体实现,今天看《oracle concept》看到下面话终于明白了一些: Flexibility for Data Loads and Identification of Integrity Violations

You can disable integrity constraints temporarily so that large amounts of data can be loaded without the overhead of constraint checking. When the data load is complete,you can easily enable the integrity constraints, and you can automatically report any new rows that violate integrity constraints to a separate exceptions table.

看来oracle这点上做的比较完善,还可以将违反完整性约束的数据自动记录到一个exception表中。

在load的时候去掉sequential file的header和footer 今天在论坛看到的方法,先记录下来: 方法一:

在sequential file stage中有个属性可以ignore第一行。对于footer,如果footer使用了与正文不同的格式,可以用使用transformer stage和 @INROWNUM stage来将footer去掉。 方法二:

在sequential file的filter option中使用sed -e '$d' -e '1d'来讲header和footer去掉。 方法三: 写个before job subroutine,可以先对这个文件做各种处理,不过我想也是subroutine中调用DSExecute sed -e '$d' -e '1d'。当然Basic中也有专门对sequential file处理的函数。

datastage中Orchadmin命令的使用(转)

Orchadmin is a command line utility provided by datastage to research on data sets. The general callable format is : $orchadmin [options] [descriptor file]

1. Before using orchadmin, you should make sure that either the working directory or the $APT_ORCHHOME/etc contains the file “config.apt” OR

The environment variable $APT_CONFIG_FILE should be defined for your session. Orchadmin commands

The various commands available with orchadmin are 1. CHECK: $orchadmin check

..

.

Validates the configuration file contents like , accesibility of all nodes defined in the configuration file, scratch disk definitions and accesibility of all the nodes etc. Throws an error when config file is not found or not defined properly 2. COPY : $orchadmin copy Makes a complete copy of the datasets of source with new destination descriptor file name. Please not that

a. You cannot use UNIX cp command as it justs copies the config file to a new name. The data is not copied. b. The new datasets will be arranged in the form of the config file that is in use but not according to the old confing file that was in use with the source. 3. DELETE : $orchadmin <> [-f -x] descriptorfiles….

The unix rm utility cannot be used to delete the datasets. The orchadmin delete or rm command should be used to delete one or more persistent data sets.

-f options makes a force delete. If some nodes are not accesible then -f forces to delete the dataset partitions from accessible nodes and leave the other partitions in inaccesible nodes as orphans.

-x forces to use the current config file to be used while deleting than the one stored in data set.

4. DESCRIBE: $orchadmin describe [options] descriptorfile.ds This is the single most important command.

1. Without any option lists the no.of.partitions, no.of.segments, valid segments, and preserve partitioning flag details of the persistent dataset.

-c : Print the configuration file that is written in the dataset if any -p: Lists down the partition level information.

-f: Lists down the file level information in each partition -e: List down the segment level information .

-s: List down the meta-data schema of the information. -v: Lists all segemnts , valid or otherwise -l : Long listing. Equivalent to -f -p -s -v -e

5. DUMP: $orchadmin dump [options] descriptorfile.ds

The dump command is used to dump(extract) the records from the dataset.

Without any options the dump command lists down all the records starting from first record from first partition till last record in last partition.

-delim ‘’ : Uses the given string as delimtor for fields instead of space. -field : Lists only the given field instead of all fields. -name : List all the values preceded by field name and a colon -n numrecs : List only the given number of records per partition.

-p period(N) : Lists every Nth record from each partition starting from first record. -skip N: Skip the first N records from each partition.

-x : Use the current system configuration file rather than the one stored in dataset. 6. TRUNCATE: $orchadmin truncate [options] descriptorfile.ds

Without options deletes all the data(ie Segments) from the dataset.

-f: Uses force truncate. Truncate accessible segments and leave the inaccesible ones. -x: Uses current system config file rather than the default one stored in the dataset. -n N: Leaves the first N segments in each partition and truncates the remaining.

..

.

7. HELP: $orchadmin -help OR $orchadmin -help

Help manual about the usage of orchadmin or orchadmin commands

DataStage Job重置的三种方法

当一个Job跑到一半终止了要还原,在DS Director中主要有三种方法来还原: 1 Job-----Reset

2 Job-----Clear Status File 3 Job-----Cleanup Resource 具体细节也不懂,有时间慢慢研究

DataStage中不能删除Job

在DataStage中job不能删除,如果试着编译又出现如下错误: Error calling subroutine: DSR_EXECJOB (Action=1); check DataStage is set up correctly in project ETUDES

(Subroutine failed to complete successfully (30107)) +

(40503) A call to an OLE server has failed, or a runtime error occured within the ole itself.

解决办法:

1 首先运行命令:DELETE FROM DS_JOBS WHERE NAME = 'JobName'

2 再运行DS.CHECKER ,注意要运行DS.CHECKER必须要有exclusive access到project ,通过如下命令可以看到有谁还连接到了服务器:netstat -a |grep dsrpc

..