How does one find out the version of Apache Pig programmatically? - apache-pig

I am using Pig through Cloudera's Hue (web interface), not through the command line. And, in fact, due to corporate restrictions, I have no access to the command line, but only to the Pig Shell itself through a the web interface.
I would like to find out my version of Apache Pig by means of some command that I can issue in the Pig language itself.
Does anybody know how to do it?

You can guess the version from the logs but if you put
--version
as a 'Pig parameter' in the properties tab in the left box it will print:
Apache Pig version 0.12.0-cdh5.3.0-SNAPSHOT (rexported) compiled Sep
29 2014, 03:12:32
Run pig script using PigRunner.run() for Pig version 0.8+ Apache Pig
version 0.12.0-cdh5.3.0-SNAPSHOT (rexported) compiled Sep 29 2014,
03:12:32

You can declare a variable in the properties file as follows:
PIG_VERSION `/home/hadoop/pig/bin/pig -version|head -n 1`
Those are backticks. Now in your script, PIG_VERSION will hold the version. In my case it holds:
Apache Pig version 0.12.0 (rexported)
A quick and dirty way to check the output is to try writing a file to 'SomeDirectory/$PIG_VERSION' and it will create a nested directory structure with each word.

Related

Issue with Postgres on windows 10

I have installed PostgreSQL 13 on windows 10
When I tried to run this command:
$ which Postgres on Git Bash, It returns which: no Postgres in (/c/Users*ahmedeid/......
Could you help me solve the issue?
It seems that your PostgreSQL installation's bin directory is not on the PATH, so you cannot find the server executable.
You'll have to modify the PATH environment variable appropriately.
Another possibility is that your bash was already running when you installed PostgreSQL, so that its PATH setting is out of date. Try closing bash and start a new one. Maybe that one has the correct setting.

PMD Apex Can't find resource for rule on Windows

I'm trying to configure PMD for code analysis.
I'm using VS Code, already installed Java 10, downloaded several versions of PMD
I've installed the Apex PMD extension for VS Code and configured it as per it's instructions.
But keep getting the can't find resource error no matter which version I choose.
This is part of the output from VS Code
PMD Command: java -cp "C:\Code\pmd-bin-5.7.0\lib*" net.sourceforge.pmd.PMD -d "c:\Code\Lightning\src\classes\AccountController.cls" -f csv -R "C:\Code\ruleset\apex_default.xml"
error:Error: Command failed: java -cp "C:\Code\pmd-bin-5.7.0\lib*" net.sourceforge.pmd.PMD -d "c:\Code\Lightning\src\classes\AccountController.cls" -f csv -R "C:\Code\ruleset\apex_default.xml"
Sep 12, 2018 2:35:20 PM net.sourceforge.pmd.RulesetsFactoryUtils getRuleSets
SEVERE: Ruleset not found
net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource 'category/apex/design.xml' for rule 'ExcessiveParameterList'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Here's the current classpath: C:\Code\pmd-bin-5.7.0\lib\antlr-runtime-3.5.2.jar;C:\Code\pmd-bin-5.7.0\lib\antlr4-runtime-4.5.2-1.jar;C:\Code\pmd-bin-5.7.0\lib\asm-5.0.4.jar;C:\Code\pmd-bin-5.7.0\lib\commons-io-2.4.jar;C:\Code\pmd-bin-5.7.0\lib\commons-lang3-3.4.jar;C:\Code\pmd-bin-5.7.0\lib\groovy-2.4.7.jar;C:\Code\pmd-bin-5.7.0\lib\gson-2.5.jar;C:\Code\pmd-bin-5.7.0\lib\javacc-5.0.jar;C:\Code\pmd-bin-5.7.0\lib\jaxen-1.1.6.jar;C:\Code\pmd-bin-5.7.0\lib\jcommander-1.48.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-apex-5.7.0-apex-jorje-shaded.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-apex-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-core-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-cpp-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-cs-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-fortran-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-go-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-groovy-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-java-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-javascript-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-jsp-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-matlab-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-objectivec-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-perl-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-php-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-plsql-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-python-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-ruby-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-scala-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-swift-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-ui-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-visualforce-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-vm-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\pmd-xml-5.7.0.jar;C:\Code\pmd-bin-5.7.0\lib\rhino-1.7.7.jar;C:\Code\pmd-bin-5.7.0\lib\saxon-9.1.0.8-dom.jar;C:\Code\pmd-bin-5.7.0\lib\saxon-9.1.0.8.jar;C:\Code\pmd-bin-5.7.0\lib\scala-compiler-2.10.4.jar;C:\Code\pmd-bin-5.7.0\lib\scala-library-2.10.4.jar;C:\Code\pmd-bin-5.7.0\lib\scala-reflect-2.10.4.jar
If i run the command from command line I get a similar output.
This error is for every rule I have on my ruleset which is nothing out of the ordinary, it's the default ruleset that comes with the extension.
It works for me with PMD 6.7.0 and fails with 5.7.0:
The rule, you reference "category/apex/design.xml/ExcessiveParameterList" is available under this path only since PMD 6. With that version, we put the rules into categories.
When using PMD 5.7.0, you'll need to use the old ruleset: "rulesets/apex/complexity.xml/ExcessiveParameterList".
It's probably better to use the latest PMD version. Is there a way, to configure the Apex PMD extension?
See also https://github.com/pmd/pmd/issues/1344

Catch sql query result in file shell

I'm trying to capture the output of a sql query launched via script.
The script :
#!/bin/bash
sql articledb <<< "select toppapier from table \g \q"
The output:
INGRES TERMINAL MONITOR Copyright 2008 Ingres Corporation
Ingres Linux Version II 9.2.0 (int.lnx/143)NPTL login
Thu Aug 31 16:38:02 2017
continue
* Executing . . .
E_US0836 line 1, Column 'toppapier' not found in any specified table.
(Thu Aug 31 16:38:02 2017)
Ingres Version II 9.2.0 (int.lnx/143)NPTL logout
Thu Aug 31 16:38:02 2017
I want to redirect the output to a file and ONLY catch the error/result (here: E_US0836 line 1, Column 'toppapier' not found in any specified table.)
How may I achieve this?
The Ingres terminal monitor (sql) has some commands which would help, but I don't think these were available in 9.2.0 which is now quite elderly; it's worth checking your support position on that release.
If you're stuck on 9.2.0 and can't upgrade, I think your best bet would be to redirect output to a file and check that for errors. I usually use:
egrep "^E_[A-Z]{2}[0-9A-F]{4}"
An alternative might be to install a separate client of a later version, and use that to reach the existing 9.2.0 databases.
This would allow the use of commands within the terminal monitor to control the format of the output - such as \silent, [no]titles, \vdelim, \colformat, and \redir (useful if you want errors and query output sent to different destinations).
There's more info on those commands in the online documentation. On docs.actian.com, look for the Ingres Command Reference Guide -> Using Ingres Commands -> sql Command -> Terminal Moitor Command Summary.

Installation of Pentaho-Data integration

After extracting the Pentaho zip file I downloaded. I set my class path to JDK 1.7.0. But, upon running the Spoon.bat file I keep getting the statement: "Unable to launch your Java Virtual Machine (JVM)." How do I resolve this problem ?
NB: I have configured JAVA_HOME, JRE_HOME as stated by similar previously answered questions.
Note that Pentaho7 requires java 8.
In any case, Set the PENTAHO_JAVA_HOME=dir, where dir is the directory that contains the /bin/java.exe executable.
Alternative:
The spoon.bat [resp spoon.sh] runs first the set-pentaho-env.bat to find a suitable java. Edit this file to know in which order it searches for it. So do like me, when nobody looks at you, edit this file manually, and set _PENTAHO_JAVA_HOME and _PENTAHO_JAVA manually.
To check: In a command line shell, cd to your PDI install directory and type spoon.bat. It writes something like start "Spoon" "**some\directory**\javaw.exe" more stuff. Check that you can type **some\directory**\javaw.exe -version in your shell.
If not: in the same directory, type set-pentaho-env.bat. It writes down the PENTAHO_JAVA and PENATHO_JAVA_HOME thAt spoon will use. Edit that file until %PENTAHO_JAVA%\java.exe -version and %PENTAHO_JAVA_HOME%\java.exe -version answers the appropriate version.
In my case (for PDI 9.2.x), installing an Oracle JDK 8 solved the issue (no need to set the Java home folder explicitly)

Change jdk path for the integrated weblogic server in oracle soa suite

I keep getting this error after launching an integrated Weblogic server in Jdeveloper,
Starting WLS with line:
C:\PROGRA~1\Java\JDK18~1.0_2\bin\java -server -Xms768m -Xmx1536m -XX:PermSize=256m -XX:MaxPermSize=1024m -Dweblogic.Name=DefaultServer -Djava.security.policy=C:\Oracle\MIDDLE~1\ORACLE~1\wlserver\server\lib\weblogic.policy
-Djavax.net.ssl.trustStore=C:\Users\Idiot\AppData\Local\Temp\trustStore7893387873075798475.jks -Doracle.jdeveloper.adrs=true -Dweblogic.nodemanager.ServiceEnabled=true
-Xverify:none -Djava.endorsed.dirs=C:\PROGRA~1\Java\JDK18~1.0_2\jre\lib\endorsed;C:\Oracle\MIDDLE~1\ORACLE~1\oracle_common\modules\endorsed -Djava.protocol.handler.pkgs="oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol" -Dopss.version=12.1.3
-Digf.arisidbeans.carmlloc=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\config\fmwconfig\carml -Digf.arisidstack.home=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\config\fmwconfig\arisidprovider
-Doracle.security.jps.config=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\servers\DefaultServer\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\oracle.ossoiap_12.1.3,C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\oracle.oamprovider_12.1.3,C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\oracle.jps_12.1.3 -Dweblogic.jdbc.remoteEnabled=false -Dcommon.components.home=C:\Oracle\Middleware\Oracle_Home\oracle_common -Djrf.version=12.1.3
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1 -Doracle.server.config.dir=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\config\fmwconfig\servers\DefaultServer -Doracle.domain.config.dir=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1\config\fmwconfig -Doracle.mds.filestore.preferred=true -Dadf.version=12.1.3 -Doracle.osb.home=C:\Oracle\Middleware\Oracle_Home\osb -da
-Dwls.home=C:\Oracle\MIDDLE~1\ORACLE~1\wlserver\server -Dweblogic.home=C:\Oracle\MIDDLE~1\ORACLE~1\wlserver\server -Djps.app.credential.overwrite.allowed=true -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -da:org.apache.xmlbeans... -Dem.oracle.home=C:\Oracle\Middleware\Oracle_Home\em -DINSTANCE_HOME=C:\Users\Idiot\AppData\Roaming\JDeveloper\system12.1.3.0.41.140521.1008\DefaultDomain -Djava.awt.headless=true -Doracle.sysman.util.logging.mode=dual_mode -Dsoa.archives.dir=C:\Oracle\Middleware\Oracle_Home\soa\soa -Dsoa.oracle.home=C:\Oracle\Middleware\Oracle_Home\soa -Dsoa.instance.home=C:\Users\Idiot\AppData\Roaming\JDEVEL~1\SYSTEM~1.100\DEFAUL~1
-Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=C:\Oracle\MIDDLE~1\ORACLE~1\wlserver\server\lib\DemoTrust.jks -Doracle.xml.schema\Ignore_Duplicate_Components=true -Doracle.xdkjava.compatibility.version=11.1.1 -Doracle.soa.compatibility.version=11.1.1 -Dums.oracle.home=C:\Oracle\Middleware\Oracle_Home\oracle_common -Djava.util.logging.manager=oracle.core.ojdl.logging.ODLLogManager weblogic.Server
Stopping Derby server...
The system cannot find the path specified.
Derby server stopped.
I uninstalled the latest JDK8 and have only the 7th version in my computer. I checked my environment variables and all possible configuration files like jdev.conf and setENVvar.cmd
Has anyone faced the same issue?
Weblogic annoyingly hard codes the value of JAVA_HOME in ORACLE_HOME\wlserver\common\bin\commEnv.cmd around line 103. The shell version of the script does at least give the option to override this as long as both JAVE_HOME and JAVA_VENDOR are set, but there's no such feature in the Windows script I'm afraid - you just have to edit the file.
The Oracle installer puts the JDK path into several configuration files. You can find them by running e.g. this command within your Oracle_Home directory:
find . -type f -exec grep -H 'jdk1.8.0_31' '{}' \;
In my case the list was:
./inventory/Components/oracle.fmwconfig.common.wls/12.2.1.0.0/context.xml
./inventory/Components/oracle.nginst.core/13.3.0.0.0/context.xml
./inventory/Components/oracle.wls.core.app.server/12.2.1.0.0/context.xml
./inventory/Components/oracle.wls.core.app.server/12.2.1.0.0/installIP2Log.xml
./jdeveloper/jdev/bin/jdev.conf
./oep/common/lib/metaInstallUnix.properties
./oep/common/lib/metaInstallWindows.properties
./oep/utils/load-generator/runloadgen.cmd
./oep/utils/load-generator/runloadgen.sh
./OPatch/bin/listDomainPatchInventory.cmd
./OPatch/bin/listDomainPatchInventory.sh
./oracle_common/common/bin/commBaseEnv.cmd
./oracle_common/common/bin/commBaseEnv.sh
./oracle_common/common/bin/setHomeDirs.cmd
./oracle_common/common/bin/setHomeDirs.sh
./oui/bin/compareInventory.cmd
./oui/bin/compareInventory.sh
./oui/bin/internal/ilaunch.cmd
./oui/bin/launch.sh
./oui/bin/viewInventory.cmd
./oui/bin/viewInventory.sh
./oui/mw/common/framework/bin/configinternal.cmd
./oui/mw/common/framework/bin/configinternal.cmd
./oui/mw/common/framework/bin/configinternal.sh
After replacing the version, all works fine again.
In Jdev 12.1.3, the location to change is system12.1.3.??? folder /DefaultDomain/bin/setDomainEnv.cmd (or sh).
You will find the JDK path there in 3 places. Change all of them to be safe.
However, if you are running ADF on your Integrated server, you will need to resolve issues where older jars may not support Java 8. This includes the older mysql driver that Oracle wants to deploy by default.