Comments (4)
Might trying the following help your issue?
src/main/java/com/savy3/hadoop/hive/serde3/cobo/CobolNumberField.java:
public Object deserialize(byte[] rowBytes) throws CobolSerdeException {
byte[] temp = transcodeField(super.getBytes(rowBytes));
String s1 = new String(temp);
if (this.compType > 0) {
if (this.compType == 3) {
s1 = unpackData(super.getBytes(rowBytes), this.decimalLocation);
}else if(this.compType == 4){
s1 = getBinary(super.getBytes(rowBytes), this.decimalLocation);
}
//} else if (this.decimalLocation > 0) {
} else {
//Now calling unpackSign on all numeric fields for which compType resolves to 0.
//
//The function will check to see if the least significant byte has been overpunched with a sign and
//return a negative number if a negative sign is found.
s1 = unpackSign(super.getBytes(rowBytes), this.decimalLocation);
}
//Adding unpackSign to handle signed fields (sign overpunched into the least significant byte)
public String unpackSign(byte[] packedData, int decimalPointLocation) {
String unpackedData = "";
final int negativeSign = 13;
for (int currentByteIndex = 0; currentByteIndex < packedData.length; currentByteIndex++) {
int firstDigit = ((packedData[currentByteIndex] >> 4) & 0x0f);
int secondDigit = (packedData[currentByteIndex] & 0x0F);
//System.out.println("unpack_"+firstDigit+"_"+secondDigit);
unpackedData += String.valueOf(secondDigit);
if (currentByteIndex == (packedData.length - 1)) {
if (firstDigit == negativeSign) {
unpackedData = "-" + unpackedData;
}
}
}
if (decimalPointLocation > 0) {
unpackedData = unpackedData.substring(0,
(unpackedData.length() - decimalPointLocation))
+ "."
+ unpackedData.substring(unpackedData.length()
- decimalPointLocation);
}
return unpackedData;
}
from cobol-to-hive.
ok, so what happens to the
else if (this.decimalLocation > 0)
block? Are you removing it completely?
Also does the try/catch
after the if then else
stay as it is?
sorry*
ah I see that you have added it in the unpackSign
method
ok let me try to build and give it a shot.
thanks much.
from cobol-to-hive.
@dfntrs Thanks for the contribution. I have added the your code to the branch https://github.com/rbheemana/Cobol-to-Hive/tree/Issue%2351-Field-with-format-S9(11)V99-displays-null-value-in-hive
@dfntrs @ameet123 Could you please test if all scenarios are working fine with the new branch jar
from cobol-to-hive.
closing the issue
from cobol-to-hive.
Related Issues (20)
- large Files HOT 3
- Variable Block Duplicates HOT 2
- V9(6) in copybook -- not able to create column HOT 14
- how to remove header and trailer from binary file. HOT 4
- Execution error HiveException: Duplicate column name HOT 7
- How to handle multiple 01 level in copybook HOT 6
- how to handle Header and Trailer from this JAR HOT 1
- Issue with redefines with picture clause (which is not group) HOT 5
- ISSUE WITH PICTURE CLAUSE S99V999 COMP-3. HOT 1
- Db2 to Hive - handling Comp and comp3 data , which are part of a group variable HOT 1
- S9(18) COMP-3 or greater value is returning null Value
- facing issues while importing data from mainframe HOT 3
- Field with format S9(11)V99 displays null value in hive. HOT 7
- Add support for unit Testing
- How to handle the COBOL EBCDIC file with header of 115 bytes. HOT 1
- Failing count(*) for the 1st time under beeline and also using prior table length (FB) HOT 21
- Simple For loop Does not work properly HOT 1
- S99. is converted as 3 but in mainframe it is considered as 2/SNUM
- Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobol-to-hive.