SqoopIDFUtils { @SuppressWarnings("unchecked") public static String toCSVMap(Map<Object, Object> map, Column column) { JSONObject object = new JSONObject(); object.putAll(map); return encloseWithQuotes(object.toJSONString()); }  static boolean isInteger(Column column); static String toCSVFixedPoint(Object obj, Column column); static Object toFixedPoint(String csvString, Column column); static String toCSVFloatingPoint(Object obj, Column column); static Object toFloatingPoint(String csvString, Column column); static String toCSVDecimal(Object obj); static Object toDecimal(String csvString, Column column); static String toCSVBit(Object obj); static Object toBit(String csvString); static String toCSVDate(Object obj); static String toCSVTime(Object obj, Column col); static Object toDate(String csvString, Column column); static Object toTime(String csvString, Column column); static String toCSVLocalDateTime(Object obj, Column col); static String toCSVDateTime(Object obj, Column col); static Object toDateTime(String csvString, Column column); static Long toDateTimeInMillis(String csvString, Column column); @SuppressWarnings("unchecked") static String toCSVMap(Map<Object, Object> map, Column column); static Map<Object, Object> toMap(String csvString); static List<Object> toList(JSONArray array); @SuppressWarnings("unchecked") static Map<Object, Object> toMap(JSONObject object); @SuppressWarnings("unchecked") static String toCSVList(Object[] list, Column column); static Object[] toList(String csvString); @SuppressWarnings("unchecked") static JSONArray toJSONArray(Object[] objectArray); static List<Object> toList(Object[] objectArray); @SuppressWarnings("unchecked") static Object[] toObjectArray(List<Object> list); static String toCSVString(String string); static String toText(String string); static String toCSVByteArray(Object obj); static byte[] toByteArray(String csvString); static String encloseWithQuotes(String string); static String removeQuotes(String string); static boolean isColumnListType(Column listType); static boolean isColumnStringType(Column stringType); @SuppressWarnings("unchecked") static String toCSV(Object[] objectArray, Schema schema); static String[] parseCSVString(String csvText); static Object[] fromCSV(String csvText, Schema schema); static final String NULL_VALUE; static final String BYTE_FIELD_CHARSET; static final Map<Character, String> ORIGINALS; static final char CSV_SEPARATOR_CHARACTER; static final char ESCAPE_CHARACTER; static final char QUOTE_CHARACTER; static final DateTimeFormatter dtfWithFractionAndTimeZone; static final DateTimeFormatter dtfWithNoFractionAndTimeZone; static final DateTimeFormatter dtfWithFractionNoTimeZone; static final DateTimeFormatter dtfWithNoFractionWithTimeZone; static final DateTimeFormatter df; static final DateTimeFormatter tfWithFraction; static final DateTimeFormatter tfWithNoFraction; static final String[] TRUE_BIT_VALUES; static final Set<String> TRUE_BIT_SET; static final String[] FALSE_BIT_VALUES; static final Set<String> FALSE_BIT_SET; }
@Test public void testEncodeMapToCSVString() { List<String> list = new ArrayList<String>(); list.add("A"); list.add("B"); Map<Object, Object> map = new HashMap<Object, Object>(); map.put("A", list); org.apache.sqoop.schema.type.Map mapCol = new org.apache.sqoop.schema.type.Map("a", new Text("t"), new Array("r", new Text( "tr"))); String encodedText = toCSVMap(map, mapCol); assertEquals(encodedText, "'{\"A\":[\"A\",\"B\"]}'"); }